Class ExistingGenerator
java.lang.Object
com.comphenix.protocol.reflect.instances.ExistingGenerator
- All Implemented Interfaces:
InstanceProvider
Provides instance constructors using a list of existing values.
Only one instance per individual class.
-
Method Summary
Modifier and TypeMethodDescriptionCreate an instance given a type, if possible.static ExistingGeneratorfromObjectArray(Object[] values) Create an instance generator from a pre-defined array of values.static ExistingGeneratorfromObjectFields(Object object) Automatically create an instance provider from a objects public and private fields.static ExistingGeneratorfromObjectFields(Object object, Class<?> type) Automatically create an instance provider from a objects public and private fields.
-
Method Details
-
fromObjectFields
Automatically create an instance provider from a objects public and private fields.If two or more fields share the same type, the last declared non-null field will take precedent.
- Parameters:
object- - object to create an instance generator from.- Returns:
- The instance generator.
-
fromObjectFields
Automatically create an instance provider from a objects public and private fields.If two or more fields share the same type, the last declared non-null field will take precedent.
- Parameters:
object- - object to create an instance generator from.type- - the type to cast the object.- Returns:
- The instance generator.
-
fromObjectArray
Create an instance generator from a pre-defined array of values.- Parameters:
values- - values to provide.- Returns:
- An instance provider that uses these values.
-
create
Description copied from interface:InstanceProviderCreate an instance given a type, if possible.- Specified by:
createin interfaceInstanceProvider- Parameters:
type- - type to create.- Returns:
- The instance, or NULL if the type cannot be created.
-