|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.vraptor.reflection.ReflectionUtil
public class ReflectionUtil
Wrapper class to deal with some reflection. TODO: this is too much procedural work, should change to an instance. Take care of synchronization issues.
| Constructor Summary | |
|---|---|
ReflectionUtil()
|
|
| Method Summary | ||
|---|---|---|
static
|
findAnnotation(Annotation[] annotations,
Class<T> clazz)
Tries to find an specific annotation inside an array |
|
static Method |
findGetter(Class type,
String property)
|
|
static Method |
findSetter(Object current,
String property)
Retrieves the setter method in an object for the specified property |
|
static Object |
genericInstantiate(Class<?> type)
Tries to instantiate an array of size 0 or type |
|
static Object |
get(Object component,
Field field)
|
|
static Field |
getField(Class containingType,
String field)
|
|
static Map<String,Method> |
getGetters(Class clazz)
Returns all getter (and iser) methods from the given class, excluding inherited ones, mapped by its property name. |
|
static Method |
getPrefixedMethod(Class<?> clazz,
String prefix,
String name,
Class... parameterTypes)
Returns a prefixed method. |
|
static
|
instantiate(Class<T> clazz)
Instantiates a class. |
|
static Object |
instantiate(String clazz)
Tries to instantiate this class |
|
static Object |
instantiateCollection(Type type)
|
|
static Object |
invoke(Object object,
Method method,
Object... parameters)
Wrapper for method invocation |
|
static boolean |
isGetter(Method m)
|
|
static
|
loadOutjecters(Class<T> type)
|
|
static
|
readAnnotations(Class type,
Class<T> annot)
Read all field annotations from one type |
|
static void |
setField(Object component,
Field field,
Object value)
Sets a field (must be accessible) |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ReflectionUtil()
| Method Detail |
|---|
public static <T> T instantiate(Class<T> clazz)
throws ComponentInstantiationException
ComponentInstantiationException - if something wrong occurs
public static Object invoke(Object object,
Method method,
Object... parameters)
throws MethodInvocationException
object - objectmethod - methodparameters - parameters
MethodInvocationException
public static void setField(Object component,
Field field,
Object value)
throws SettingException
component - componentfield - fieldvalue - new value
SettingException - unable to call setter
public static Object get(Object component,
Field field)
throws GettingException
GettingException
public static Method findGetter(Class type,
String property)
throws MethodInvocationException
MethodInvocationException
public static Method findSetter(Object current,
String property)
current - the current objectproperty - the setter to find
public static <T extends Annotation> List<FieldAnnotation<T>> readAnnotations(Class type,
Class<T> annot)
public static Object genericInstantiate(Class<?> type)
throws ComponentInstantiationException
type - type
ComponentInstantiationException - problem instantiating it
public static Object instantiateCollection(Type type)
throws ComponentInstantiationException
ComponentInstantiationException
public static <T extends Annotation> T findAnnotation(Annotation[] annotations,
Class<T> clazz)
T - the annotation typeannotations - the arrayclazz - the annotation class to be found
public static Object instantiate(String clazz)
throws ComponentInstantiationException
class - the class to instantiate
ComponentInstantiationException
public static Method getPrefixedMethod(Class<?> clazz,
String prefix,
String name,
Class... parameterTypes)
clazz - the clazz where we are looking for a methodprefix - the method prefixname - the suffix
MethodInvocationException - unsufficient rights to look for such method
public static Field getField(Class containingType,
String field)
throws GettingException
GettingExceptionpublic static Map<String,Method> getGetters(Class clazz)
name -> getName
closed -> isClosed
clazz -
public static boolean isGetter(Method m)
public static <T> List<Outjecter> loadOutjecters(Class<T> type)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||