JavassistBuilder¶
-
public final class
JavassistBuilder
¶ Builder class for javassist related tasks. Helps with building appropriate elements of class e.g. fields, getters, field initializer
Methods¶
createCollectionInitializer¶
createEnumInitializer¶
createField¶
-
public static CtField
createField
(CtClass declaring, CtClass type, String name, String genericSignature)¶ Creates class field with the given name for the given class declaration and type.
Parameters: - declaring – the class to which the field will be added
- type – the field type
- name – the field name
- genericSignature – the generic signature
Throws: - CannotCompileException – when bytecode transformation has failed
Returns: An instance of
javassist.CtField
represents a field
createGetter¶
-
public static CtMethod
createGetter
(String fieldName, CtClass declaring, CtField field)¶ Creates a public getter method with the given field name for the given class declaration and type.
Parameters: - fieldName – the field name
- declaring – the class to which the getter will be added
- field – the field declaration
Throws: - CannotCompileException – when bytecode transformation has failed
Returns: An instance of
javassist.CtMethod
represents a getter method
createInitializer¶
createInitializer¶
createJavaTimeInitializer¶
-
public static CtField.Initializer
createJavaTimeInitializer
(String type, String defaultValue)¶ Makes a initializer for
java.time.LocalDate
orjava.time.LocalDateTime
classParameters: - type – the field type
- defaultValue – the default value as string
Returns: java.time.LocalDate
orjava.time.LocalDateTime
initializer based on a type parameter
createListInitializer¶
createLocaleInitializer¶
-
public static CtField.Initializer
createLocaleInitializer
(Object defaultValue)¶ Makes an initializer for
java.util.Locale
class.Parameters: - defaultValue – the default value
Returns: java.util.Locale
initializer
createSetInitializer¶
createSetter¶
-
public static CtMethod
createSetter
(String fieldName, CtField field)¶ Creates a public setter method with the given field name for the given class declaration and type.
Parameters: - fieldName – the field name
- field – the field declaration
Throws: - CannotCompileException – when bytecode transformation has failed
Returns: An instance of
javassist.CtMethod
represents a setter method