Package io.activej.codegen
Class ClassBuilder<T>
java.lang.Object
io.activej.codegen.ClassBuilder<T>
- Type Parameters:
T- type of item
- All Implemented Interfaces:
WithInitializer<ClassBuilder<T>>
public final class ClassBuilder<T> extends Object implements WithInitializer<ClassBuilder<T>>
Intends for dynamic description of the behaviour of the object in runtime
-
Field Summary
Fields Modifier and Type Field Description static StringCLASS_BUILDER_MARKERstatic StringDEFAULT_CLASS_NAMEprotected Map<String,Class<?>>fieldsprotected List<Class<?>>interfacesprotected Map<org.objectweb.asm.commons.Method,Expression>methodsprotected Map<org.objectweb.asm.commons.Method,Expression>staticMethodsprotected Class<?>superclass -
Method Summary
Modifier and Type Method Description Class<T>build()TbuildClassAndCreateNewInstance()TbuildClassAndCreateNewInstance(Class<?>[] constructorParameterTypes, Object[] constructorParameters)TbuildClassAndCreateNewInstance(Object... constructorParameters)static <T> ClassBuilder<T>create(DefiningClassLoader classLoader, Class<? super T> implementation, Class<?>... interfaces)static <T> ClassBuilder<T>create(DefiningClassLoader classLoader, Class<? super T> implementation, List<Class<?>> interfaces)DefiningClassLoadergetClassLoader()static ObjectgetStaticConstant(int id)voidsetStaticMethod(String methodName, Class<?> returnClass, List<? extends Class<?>> argumentTypes, Expression expression)ClassBuilder<T>withBytecodeSaveDir(Path bytecodeSaveDir)ClassBuilder<T>withClassKey(Object... keyParameters)ClassBuilder<T>withClassName(String name)ClassBuilder<T>withConstructor(Expression expression)ClassBuilder<T>withField(String field, Class<?> type)Creates a new field for a dynamic classClassBuilder<T>withField(String field, Class<?> type, Expression value)ClassBuilder<T>withFinalField(String field, Class<?> type, Expression value)ClassBuilder<T>withMethod(String methodName, Expression expression)CCreates a new method for a dynamic classClassBuilder<T>withMethod(String methodName, Class<?> returnType, List<? extends Class<?>> argumentTypes, Expression expression)Creates a new method for a dynamic classClassBuilder<T>withStaticField(String field, Class<?> type)ClassBuilder<T>withStaticField(String field, Class<?> type, Expression value)ClassBuilder<T>withStaticFinalField(String field, Class<?> type, Expression value)ClassBuilder<T>withStaticInitializer(Expression expression)ClassBuilder<T>withStaticMethod(String methodName, Class<?> returnClass, List<? extends Class<?>> argumentTypes, Expression expression)
-
Field Details
-
Method Details
-
create
public static <T> ClassBuilder<T> create(DefiningClassLoader classLoader, Class<? super T> implementation, Class<?>... interfaces) -
create
public static <T> ClassBuilder<T> create(DefiningClassLoader classLoader, Class<? super T> implementation, List<Class<?>> interfaces) -
withBytecodeSaveDir
-
withClassKey
-
withClassName
-
withStaticInitializer
-
withConstructor
-
withField
Creates a new field for a dynamic class- Parameters:
field- name of fieldtype- type of field- Returns:
- changed AsmFunctionFactory
-
withField
-
withFinalField
-
withMethod
public ClassBuilder<T> withMethod(String methodName, Class<?> returnType, List<? extends Class<?>> argumentTypes, Expression expression)Creates a new method for a dynamic class- Parameters:
methodName- name of methodreturnType- type which returns this methodargumentTypes- list of types of argumentsexpression- function which will be processed- Returns:
- changed AsmFunctionFactory
-
withMethod
CCreates a new method for a dynamic class- Parameters:
methodName- name of methodexpression- function which will be processed- Returns:
- changed AsmFunctionFactory
-
withStaticMethod
public ClassBuilder<T> withStaticMethod(String methodName, Class<?> returnClass, List<? extends Class<?>> argumentTypes, Expression expression) -
setStaticMethod
public void setStaticMethod(String methodName, Class<?> returnClass, List<? extends Class<?>> argumentTypes, Expression expression) -
withStaticField
-
withStaticField
-
withStaticFinalField
-
getStaticConstant
-
build
-
buildClassAndCreateNewInstance
-
buildClassAndCreateNewInstance
-
buildClassAndCreateNewInstance
-
getClassLoader
-