public class MetaClass
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
MetaClass.ClassCreationException |
static class |
MetaClass.ClassFactory<T> |
static class |
MetaClass.ConstructorNotFoundException |
Constructor and Description |
---|
MetaClass(java.lang.Class<?> classname)
Creates a new MetaClass producing objects of the given type
|
MetaClass(java.lang.String classname)
Creates a new MetaClass producing objects of the given type
|
Modifier and Type | Method and Description |
---|---|
static <E> E |
cast(java.lang.String value,
java.lang.reflect.Type type)
Cast a String representation of an object into that object.
|
static <E> E |
castWithoutKnowingType(java.lang.String value) |
boolean |
checkConstructor(java.lang.Object... params) |
static MetaClass |
create(java.lang.Class<?> clazz)
Creates a new MetaClass (helper method)
|
static MetaClass |
create(java.lang.String classname)
Creates a new MetaClass (helper method)
|
<E> MetaClass.ClassFactory<E> |
createFactory(java.lang.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(java.lang.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(java.lang.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(java.lang.Class<E> type,
java.lang.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(java.lang.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(java.lang.Object o) |
int |
hashCode() |
java.lang.String |
toString() |
public MetaClass(java.lang.String classname)
classname
- The full classname of the objects to createpublic MetaClass(java.lang.Class<?> classname)
classname
- The class to createpublic <E> MetaClass.ClassFactory<E> createFactory(java.lang.Class<?>... classes)
E
- The type of the objects to be producedclasses
- The types used in the constructorpublic <E> MetaClass.ClassFactory<E> createFactory(java.lang.String... classes)
E
- The type of the objects to be producedclasses
- The types used in the constructorpublic <E> MetaClass.ClassFactory<E> createFactory(java.lang.Object... objects)
E
- The type of the objects to be producedobjects
- Instances of the types used in the constructorpublic <E> E createInstance(java.lang.Object... objects)
E
- The type of the object returnedobjects
- The arguments to the constructor of the classpublic <E,F extends E> F createInstance(java.lang.Class<E> type, java.lang.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(java.lang.Object... params)
public java.lang.String toString()
toString
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public static MetaClass create(java.lang.String classname)
classname
- The name of the class to createpublic static MetaClass create(java.lang.Class<?> clazz)
clazz
- The class to createpublic static <E> E cast(java.lang.String value, java.lang.reflect.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(java.lang.String value)