public class MetaClass extends Object
Modifier and Type | Class and Description |
---|---|
static class |
MetaClass.ClassCreationException |
static class |
MetaClass.ClassFactory<T> |
static class |
MetaClass.ConstructorNotFoundException |
Constructor and Description |
---|
MetaClass(Class<?> classname)
Creates a new MetaClass producing objects of the given type
|
MetaClass(String classname)
Creates a new MetaClass producing objects of the given type
|
Modifier and Type | Method and Description |
---|---|
static <E> E |
cast(String value,
Type type)
Cast a String representation of an object into that object.
|
static <E> E |
castWithoutKnowingType(String value) |
boolean |
checkConstructor(Object... params) |
static MetaClass |
create(Class<?> clazz)
Creates a new MetaClass (helper method)
|
static MetaClass |
create(String classname)
Creates a new MetaClass (helper method)
|
<E> MetaClass.ClassFactory<E> |
createFactory(Class<?>... classes)
Creates a factory for producing instances of this class from a
constructor taking the given types as arguments
|
<E> MetaClass.ClassFactory<E> |
createFactory(Object... objects)
Creates a factory for producing instances of this class from a
constructor taking objects of the types given
|
<E> MetaClass.ClassFactory<E> |
createFactory(String... classes)
Creates a factory for producing instances of this class from a
constructor taking the given types as arguments
|
<E,F extends E> |
createInstance(Class<E> type,
Object... params)
Creates an instance of the class, forcing a cast to a certain type and
given an array of objects as constructor parameters NOTE: the resulting
instance will [unlike java] invoke the most narrow constructor rather
than the one which matches the signature passed to this function
|
<E> E |
createInstance(Object... objects)
Create an instance of the class, inferring the type automatically, and
given an array of objects as constructor parameters NOTE: the resulting
instance will [unlike java] invoke the most narrow constructor rather
than the one which matches the signature passed to this function
|
boolean |
equals(Object o) |
int |
hashCode() |
String |
toString() |
public MetaClass(String classname)
classname
- The full classname of the objects to createpublic MetaClass(Class<?> classname)
classname
- The class to createpublic <E> MetaClass.ClassFactory<E> createFactory(Class<?>... classes)
E
- The type of the objects to be producedclasses
- The types used in the constructorpublic <E> MetaClass.ClassFactory<E> createFactory(String... classes)
E
- The type of the objects to be producedclasses
- The types used in the constructorpublic <E> MetaClass.ClassFactory<E> createFactory(Object... objects)
E
- The type of the objects to be producedobjects
- Instances of the types used in the constructorpublic <E> E createInstance(Object... objects)
E
- The type of the object returnedobjects
- The arguments to the constructor of the classpublic <E,F extends E> F createInstance(Class<E> type, Object... params)
E
- The type of the object returnedtype
- The class of the object returnedparams
- The arguments to the constructor of the classpublic boolean checkConstructor(Object... params)
public static MetaClass create(String classname)
classname
- The name of the class to createpublic static MetaClass create(Class<?> clazz)
clazz
- The class to createpublic static <E> E cast(String value, Type type)
E
- The type of the object returned (same as type)value
- The string representation of the objecttype
- The type (usually class) to be returned (same as E)public static <E> E castWithoutKnowingType(String value)