diff options
author | zaaarf <zaaarf@proton.me> | 2023-03-21 12:27:27 +0100 |
---|---|---|
committer | zaaarf <zaaarf@proton.me> | 2023-03-21 12:27:27 +0100 |
commit | 12955162326c89f1c6cf44e130efa80c9145f934 (patch) | |
tree | d09663d2093f85347829b031ab3c7bb82e5e2347 /src/main/java/ftbsc/lll/proxies/FieldProxy.java | |
parent | 45ed48b675ea6f0bb43fb2d7d59d0505a6a9e8b6 (diff) |
feat: initial proxy rework, replaced getters with public constants, rely more on ow2 Types instead of homebrew solutions
Diffstat (limited to 'src/main/java/ftbsc/lll/proxies/FieldProxy.java')
-rw-r--r-- | src/main/java/ftbsc/lll/proxies/FieldProxy.java | 65 |
1 files changed, 6 insertions, 59 deletions
diff --git a/src/main/java/ftbsc/lll/proxies/FieldProxy.java b/src/main/java/ftbsc/lll/proxies/FieldProxy.java index 0edd735..72a4e40 100644 --- a/src/main/java/ftbsc/lll/proxies/FieldProxy.java +++ b/src/main/java/ftbsc/lll/proxies/FieldProxy.java @@ -1,6 +1,5 @@ package ftbsc.lll.proxies; -import ftbsc.lll.tools.DescriptorBuilder; import org.objectweb.asm.Type; import java.lang.reflect.Field; @@ -11,40 +10,24 @@ import java.lang.reflect.Field; * @since 0.3.0 */ public class FieldProxy extends AbstractProxy { - - /** - * The descriptor of the field's type. - */ - private final String typeDescriptor; - /** * A public constructor, builds a proxy from a {@link Field} * obtained from reflection. * @param f the {@link Field} object corresponding to this. */ public FieldProxy(Field f) { - super(f.getName(), f.getModifiers(), Type.getInternalName(f.getDeclaringClass())); - this.typeDescriptor = Type.getDescriptor(f.getType()); + super(f.getName(), Type.getType(f.getType()), f.getModifiers(), Type.getInternalName(f.getDeclaringClass())); } /** - * A protected constructor, called only from the builder. + * Protected constructor, called only from the builder. * @param name the name of the field + * @param type the {@link Type} of the field * @param modifiers the modifiers of the field * @param parent the FQN of the parent class of the field - * @param typeDescriptor the type descriptor of the field - */ - FieldProxy(String name, int modifiers, String parent, String typeDescriptor) { - super(name, modifiers, parent); - this.typeDescriptor = typeDescriptor; - } - - /** - * @return the field's type descriptor */ - @Override - public String getDescriptor() { - return typeDescriptor; + protected FieldProxy(String name, Type type, int modifiers, String parent) { + super(name, type, modifiers, parent); } /** @@ -61,11 +44,6 @@ public class FieldProxy extends AbstractProxy { */ public static class Builder extends AbstractProxy.Builder<FieldProxy> { /** - * The descriptor of the field's type. - */ - private String typeDescriptor; - - /** * The constructor of the builder, used only internally. * @param name the name of the field */ @@ -74,43 +52,12 @@ public class FieldProxy extends AbstractProxy { } /** - * Sets the descriptor of the field type to the given {@link String}. - * @param typeDescriptor the descriptor of the field type - * @return the builder's state after the change - */ - public Builder setDescriptor(String typeDescriptor) { - this.typeDescriptor = typeDescriptor; - return this; - } - - /** - * Sets the descriptor of the field type to match the give {@link Class}. - * @param fqn the fully qualified name of the field type - * @param arrayLevel the array level of the field type - * @return the builder's state after the change - */ - public Builder setType(String fqn, int arrayLevel) { - this.typeDescriptor = DescriptorBuilder.nameToDescriptor(fqn, arrayLevel); - return this; - } - - /** - * Sets the descriptor of the field type to match the give {@link Class}. - * @param type a {@link Class} object representing the field type - * @return the builder's state after the change - */ - public Builder setType(Class<?> type) { - this.typeDescriptor = Type.getDescriptor(type); - return this; - } - - /** * Builds a {@link FieldProxy} of the given kind. * @return the built {@link FieldProxy} */ @Override public FieldProxy build() { - return new FieldProxy(this.name, this.modifiers, this.parent, this.typeDescriptor); + return new FieldProxy(this.name, this.type, this.modifiers, this.parent); } } } |