diff options
Diffstat (limited to 'src/main/java/ftbsc/lll/proxies/AbstractProxy.java')
-rw-r--r-- | src/main/java/ftbsc/lll/proxies/AbstractProxy.java | 98 |
1 files changed, 54 insertions, 44 deletions
diff --git a/src/main/java/ftbsc/lll/proxies/AbstractProxy.java b/src/main/java/ftbsc/lll/proxies/AbstractProxy.java index 1ee19a8..4dd2a72 100644 --- a/src/main/java/ftbsc/lll/proxies/AbstractProxy.java +++ b/src/main/java/ftbsc/lll/proxies/AbstractProxy.java @@ -1,5 +1,7 @@ package ftbsc.lll.proxies; +import org.objectweb.asm.Type; + /** * Abstract proxy class, implementing common aspects * of {@link MethodProxy} and {@link FieldProxy}. @@ -8,57 +10,38 @@ package ftbsc.lll.proxies; public abstract class AbstractProxy { /** - * The name of the corresponding class member. + * The name of the corresponding element. */ - private final String name; + public final String name; - /** - * The fully qualified name (i.e. java.lang.String) of - * the parent class. - */ - private final String parent; /** - * The modifiers of the member, as a packed int. - * @see java.lang.reflect.Modifier + * The {@link Type} corresponding to this element. */ - private final int modifiers; + public final Type type; /** - * @return the name of the item + * The fully qualified name (i.e. java.lang.String) of + * the parent class. */ - public String getName() { - return this.name; - } + public final String parent; /** - * @return the modifiers of the member, as a packed int + * The modifiers of the element, as a packed int. * @see java.lang.reflect.Modifier */ - public int getModifiers() { - return this.modifiers; - } - - /** - * @return the fully qualified name of the parent class - */ - public String getParent() { - return this.parent; - } - - /** - * @return the descriptor of the member - */ - public abstract String getDescriptor(); + public final int modifiers; /** * The private constructor, should be called by all classes extending this in theirs. - * @param name the name of the member + * @param name the name of the element + * @param type the {@link Type} for the element * @param modifiers the modifiers, as a packed int * @param parent the FQN of the parent class */ - protected AbstractProxy(String name, int modifiers, String parent) { + protected AbstractProxy(String name, Type type, int modifiers, String parent) { this.name = name; + this.type = type; this.modifiers = modifiers; this.parent = parent; } @@ -70,12 +53,12 @@ public abstract class AbstractProxy { public abstract static class Builder<T extends AbstractProxy> { /** - * The name of the member. + * The name of the element. */ - protected final String name; + protected String name; /** - * The modifiers of the member, as a packed int. + * The modifiers of the element, as a packed int. */ protected int modifiers; @@ -85,14 +68,38 @@ public abstract class AbstractProxy { protected String parent; /** + * The {@link Type} corresponding to the element. + */ + protected Type type; + + /** * The constructor. - * @param name the name of the member + * @param name the name of the element */ protected Builder(String name) { this.name = name; this.modifiers = 0; } + + /** + * @param newModifier the modifier to add + * @return the current state of the builder + */ + public Builder<T> addModifier(int newModifier) { + this.modifiers |= newModifier; + return this; + } + + /** + * @param newModifier the new modifier value + * @return the current state of the builder + */ + public Builder<T> setModifiers(int newModifier) { + this.modifiers = newModifier; + return this; + } + /** * @param parentFQN the fully qualified name of the parent * @return the current state of the builder @@ -103,23 +110,26 @@ public abstract class AbstractProxy { } /** - * @param newModifier the modifier to add + * @param type the {@link Type} corresponding to the element * @return the current state of the builder */ - public Builder<T> addModifier(int newModifier) { - this.modifiers |= newModifier; + public Builder<T> setType(Type type) { + this.type = type; return this; } + /** - * @param newModifier the new modifier value - * @return the current state of the builder + * Sets {@link Type} for this element from the descriptor, passed as a {@link String}. + * @param descriptor the descriptor passed as a {@link String} + * @return the builder's state after the change */ - public Builder<T> setModifier(int newModifier) { - this.modifiers = newModifier; - return this; + public Builder<T> setDescriptor(String descriptor) { + return this.setType(Type.getType(descriptor)); } + + /** * @return the built proxy object */ |