Skip to content

Commit e8c594f

Browse files
committed
Merge branch 'release-0.2.0'
2 parents 01be654 + 7a74256 commit e8c594f

File tree

5 files changed

+39
-21
lines changed

5 files changed

+39
-21
lines changed

bombe-asm/src/main/java/me/jamiemansfield/bombe/asm/analysis/ClassNodeClassInfo.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ class ClassNodeClassInfo extends InheritanceProvider.ClassInfo.Impl {
5151
);
5252
this.interfaces.addAll(klass.interfaces);
5353
klass.fields.stream()
54-
.map(fieldNode -> new FieldSignature(fieldNode.name, fieldNode.desc))
54+
.map(fieldNode -> FieldSignature.of(fieldNode.name, fieldNode.desc))
5555
.forEach(this.fields::add);
5656
klass.methods.stream()
57-
.map(methodNode -> new MethodSignature(methodNode.name, methodNode.desc))
57+
.map(methodNode -> MethodSignature.of(methodNode.name, methodNode.desc))
5858
.forEach(this.methods::add);
5959
}
6060

bombe-core/src/main/java/me/jamiemansfield/bombe/type/signature/FieldSignature.java

+10-8
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,15 @@ public class FieldSignature extends MemberSignature {
4747
private final FieldType type;
4848

4949
/**
50-
* Creates a field signature, with the given name and type.
50+
* Creates a new field signature with the given name and
51+
* decoded type descriptor.
5152
*
5253
* @param name The name of the field
53-
* @param type The type of the field
54+
* @param type The raw type of the field
55+
* @return The new field signature
5456
*/
55-
public FieldSignature(final String name, final FieldType type) {
56-
super(name);
57-
this.type = type;
57+
public static FieldSignature of(String name, String type) {
58+
return new FieldSignature(name, FieldType.of(type));
5859
}
5960

6061
/**
@@ -63,8 +64,9 @@ public FieldSignature(final String name, final FieldType type) {
6364
* @param name The name of the field
6465
* @param type The type of the field
6566
*/
66-
public FieldSignature(final String name, final String type) {
67-
this(name, FieldType.of(type));
67+
public FieldSignature(final String name, final FieldType type) {
68+
super(name);
69+
this.type = type;
6870
}
6971

7072
/**
@@ -74,7 +76,7 @@ public FieldSignature(final String name, final String type) {
7476
* @since 0.1.1
7577
*/
7678
public FieldSignature(final String name) {
77-
this(name, (FieldType) null);
79+
this(name, null);
7880
}
7981

8082
/**

bombe-core/src/main/java/me/jamiemansfield/bombe/type/signature/MethodSignature.java

+22-9
Original file line numberDiff line numberDiff line change
@@ -46,24 +46,37 @@ public class MethodSignature extends MemberSignature {
4646
private final MethodDescriptor descriptor;
4747

4848
/**
49-
* Creates a method signature, with the given name and {@link MethodDescriptor}.
49+
* Creates a method signature, with the given method name and raw descriptor.
5050
*
5151
* @param name The method name
52-
* @param descriptor The method descriptor
52+
* @param descriptor The method's raw descriptor
53+
* @return The new method signature
5354
*/
54-
public MethodSignature(final String name, final MethodDescriptor descriptor) {
55-
super(name);
56-
this.descriptor = descriptor;
55+
public static MethodSignature of(final String name, final String descriptor) {
56+
return new MethodSignature(name, MethodDescriptor.of(descriptor));
5757
}
5858

5959
/**
60-
* Creates a method descriptor, with the given method name and raw descriptor.
60+
* Creates a method signature, with the given raw string that contains the
61+
* method name and descriptor concatenated.
62+
*
63+
* @param nameAndDescriptor The method name and descriptor
64+
* @return The new method signature
65+
*/
66+
public static MethodSignature of(final String nameAndDescriptor) {
67+
int methodIndex = nameAndDescriptor.indexOf('(');
68+
return of(nameAndDescriptor.substring(0, methodIndex), nameAndDescriptor.substring(methodIndex));
69+
}
70+
71+
/**
72+
* Creates a method signature, with the given name and {@link MethodDescriptor}.
6173
*
6274
* @param name The method name
63-
* @param descriptor The method's raw descriptor
75+
* @param descriptor The method descriptor
6476
*/
65-
public MethodSignature(final String name, final String descriptor) {
66-
this(name, MethodDescriptor.of(descriptor));
77+
public MethodSignature(final String name, final MethodDescriptor descriptor) {
78+
super(name);
79+
this.descriptor = descriptor;
6780
}
6881

6982
/**

build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ subprojects {
77

88
group = 'me.jamiemansfield'
99
archivesBaseName = project.name.toLowerCase()
10-
version = '0.2.0-SNAPSHOT'
10+
version = '0.2.0'
1111

1212
repositories {
1313
mavenCentral()

changelogs/0.2.0.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Big thanks to @Minecrell, for his help towards this release!
88

99
- [Drop dependency on Guava](https://github.com/jamiemansfield/Bombe/pull/1)
1010
- [Add PrimitiveType](https://github.com/jamiemansfield/Bombe/pull/2)
11+
- [Refactor Field/MethodSignature constructors](https://github.com/jamiemansfield/Bombe/pull/4)
1112

1213
## Changes
1314

@@ -16,4 +17,6 @@ Big thanks to @Minecrell, for his help towards this release!
1617
parsing of MethodDescriptors specifically.
1718
- The dependency on Guava has been dropped.
1819
- A PrimitiveType interface has been introduced, providing a direct replacement for the
19-
PrimitiveType enum that previously existed in Lorenz.
20+
PrimitiveType enum that previously existed in Lorenz.
21+
- The 'convenience' signature constructors have been replaced with `#of(String, String)`
22+
methods.

0 commit comments

Comments
 (0)