public class ClassGenerator extends Object
ClassGeneratorProvider
.Constructor and Description |
---|
ClassGenerator() |
Modifier and Type | Method and Description |
---|---|
byte[] |
createClass(Class<?> type,
String name,
Class<?> parentType,
List<? extends EventFactoryPlugin> plugins)
Create the event class.
|
byte[] |
createFactory(Class<?> type,
String name)
Create the factory for an event class.
|
static void |
generateField(ClassWriter classWriter,
org.spongepowered.api.eventgencore.Property<Class<?>,Method> property) |
static void |
generateMutator(ClassWriter cw,
Class<?> type,
String internalName,
String fieldName,
Class<?> fieldType,
org.spongepowered.api.eventgencore.Property<Class<?>,Method> property)
Generates a standard mutator method.
|
static Field |
getField(Class<?> type,
String fieldName) |
static String |
getInternalName(String name) |
NullPolicy |
getNullPolicy()
Get the policy regarding how null parameters are handled.
|
static int |
getReturnOpcode(Class<?> type)
Get the opcode used for returning from a method.
|
static boolean |
hasDeclaredMethod(Class<?> type,
String name,
Class<?>... params) |
void |
setNullPolicy(NullPolicy nullPolicy)
Set the policy regarding how null parameters are handled.
|
public static int getReturnOpcode(Class<?> type)
type
- The type being returnedpublic static boolean hasDeclaredMethod(Class<?> type, String name, Class<?>... params)
public NullPolicy getNullPolicy()
public void setNullPolicy(NullPolicy nullPolicy)
nullPolicy
- The null policypublic static void generateField(ClassWriter classWriter, org.spongepowered.api.eventgencore.Property<Class<?>,Method> property)
public static void generateMutator(ClassWriter cw, Class<?> type, String internalName, String fieldName, Class<?> fieldType, org.spongepowered.api.eventgencore.Property<Class<?>,Method> property)
This method assumes that a standard field has been generated for the provided Property
cw
- The ClassWriter
to generate the mutator intype
- The Class
of the event that's having an implementation generatedinternalName
- The internal name (slashes instead of periods in the package) of the new class being generatedfieldName
- The name of the field to mutatefieldType
- The type of the field to mutateproperty
- The Property
containing the mutator method to generate forpublic byte[] createClass(Class<?> type, String name, Class<?> parentType, List<? extends EventFactoryPlugin> plugins)
type
- The typename
- The canonical of the generated classparentType
- The parent typeClassLoader