public class LibraryClassBuilder
extends java.lang.Object
LibraryClass
instances). It provides
methods to easily add interfaces, fields, and methods, optionally with method bodies.
If you're adding many fields and methods, it is more efficient to reuse a single instance of this builder for all fields and methods that you add.
Constructor and Description |
---|
LibraryClassBuilder(int u2accessFlags,
java.lang.String className,
java.lang.String superclassName)
Creates a new ClassBuilder for the Java class with the given name and super class.
|
LibraryClassBuilder(int u2accessFlags,
java.lang.String className,
java.lang.String superclassName,
java.lang.String[] interfaceNames,
Clazz[] interfaceClasses,
int subClassCount,
Clazz[] subClasses,
LibraryField[] fields,
LibraryMethod[] methods,
KotlinMetadata kotlinMetadata)
Creates a new ClassBuilder for the Java class with the given name and super class.
|
LibraryClassBuilder(LibraryClass libraryClass)
Creates a new ClassBuilder for the given class.
|
Modifier and Type | Method and Description |
---|---|
LibraryField |
addAndReturnField(int u2accessFlags,
java.lang.String fieldName,
java.lang.String fieldDescriptor)
Adds a new field to the edited class, and returns it.
|
LibraryMethod |
addAndReturnMethod(int u2accessFlags,
java.lang.String methodName,
java.lang.String methodDescriptor)
Adds a new method to the edited class, and returns it.
|
LibraryClassBuilder |
addField(int u2accessFlags,
java.lang.String fieldName,
java.lang.String fieldDescriptor)
Adds a new field to the edited class.
|
LibraryClassBuilder |
addField(int u2accessFlags,
java.lang.String fieldName,
java.lang.String fieldDescriptor,
MemberVisitor extraMemberVisitor)
Adds a new field to the edited class.
|
LibraryClassBuilder |
addInterface(Clazz interfaceClass)
Adds a new interface to the edited class.
|
LibraryClassBuilder |
addInterface(java.lang.String interfaceName)
Adds a new interface to the edited class.
|
LibraryClassBuilder |
addInterface(java.lang.String interfaceName,
Clazz referencedInterface)
Adds a new interface to the edited class.
|
LibraryClassBuilder |
addMethod(int u2accessFlags,
java.lang.String methodName,
java.lang.String methodDescriptor)
Adds a new method to the edited class.
|
LibraryClassBuilder |
addMethod(int u2accessFlags,
java.lang.String methodName,
java.lang.String methodDescriptor,
MemberVisitor extraMemberVisitor)
Adds a new method to the edited class.
|
ConstantPoolEditor |
getConstantPoolEditor()
Returns a ConstantPoolEditor instance for the created or edited class instance.
|
LibraryClass |
getLibraryClass()
Returns the created or edited LibraryClass instance.
|
public LibraryClassBuilder(int u2accessFlags, java.lang.String className, java.lang.String superclassName)
u2accessFlags
- access flags for the new class.className
- the fully qualified name of the new class.superclassName
- the fully qualified name of the super class.VersionConstants
,
AccessConstants
public LibraryClassBuilder(int u2accessFlags, java.lang.String className, java.lang.String superclassName, java.lang.String[] interfaceNames, Clazz[] interfaceClasses, int subClassCount, Clazz[] subClasses, LibraryField[] fields, LibraryMethod[] methods, KotlinMetadata kotlinMetadata)
u2accessFlags
- access flags for the new class.className
- the fully qualified name of the new class.superclassName
- the fully qualified name of the super class.interfaceNames
- the names of the interfaces that are implemented by this class.interfaceClasses
- references to the interface classes of the interfaces that are
implemented by this class.subClassCount
- the number of subclasses of this class.subClasses
- references to the subclasses of this class.fields
- references to the fields of this class.methods
- references to the methods of this class.kotlinMetadata
- the metadata attached to this class if it is a Kotlin classVersionConstants
,
AccessConstants
public LibraryClassBuilder(LibraryClass libraryClass)
libraryClass
- the class to be edited.public LibraryClass getLibraryClass()
public ConstantPoolEditor getConstantPoolEditor()
public LibraryClassBuilder addInterface(Clazz interfaceClass)
interfaceClass
- the interface class.public LibraryClassBuilder addInterface(java.lang.String interfaceName)
interfaceName
- the name of the interface.public LibraryClassBuilder addInterface(java.lang.String interfaceName, Clazz referencedInterface)
interfaceName
- the name of the interface.referencedInterface
- the referenced interface.public LibraryClassBuilder addField(int u2accessFlags, java.lang.String fieldName, java.lang.String fieldDescriptor)
u2accessFlags
- access flags for the new field.fieldName
- name of the new field.fieldDescriptor
- descriptor of the new field.public LibraryClassBuilder addField(int u2accessFlags, java.lang.String fieldName, java.lang.String fieldDescriptor, MemberVisitor extraMemberVisitor)
u2accessFlags
- access flags for the new field.fieldName
- name of the new field.fieldDescriptor
- descriptor of the new field.public LibraryField addAndReturnField(int u2accessFlags, java.lang.String fieldName, java.lang.String fieldDescriptor)
u2accessFlags
- access flags for the new field.fieldName
- name of the new field.fieldDescriptor
- descriptor of the new field.public LibraryClassBuilder addMethod(int u2accessFlags, java.lang.String methodName, java.lang.String methodDescriptor)
u2accessFlags
- the access flags of the new method.methodName
- the name of the new method.methodDescriptor
- the descriptor of the new method.public LibraryClassBuilder addMethod(int u2accessFlags, java.lang.String methodName, java.lang.String methodDescriptor, MemberVisitor extraMemberVisitor)
u2accessFlags
- the access flags of the new method.methodName
- the name of the new method.methodDescriptor
- the descriptor of the new method.extraMemberVisitor
- an optional visitor for the method after it has been created and
added to the class.public LibraryMethod addAndReturnMethod(int u2accessFlags, java.lang.String methodName, java.lang.String methodDescriptor)
u2accessFlags
- the access flags of the new method.methodName
- the name of the new method.methodDescriptor
- the descriptor of the new method.