|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.emarsys.ecommon.util.ReflectionsHelper
public class ReflectionsHelper
Helper-methods to get things via reflection Creationdate: Sep 12, 2007
Field Summary | |
---|---|
static java.lang.String |
GET
|
static java.util.Map<java.lang.Class<?>,java.lang.Class<?>> |
primitivesToWrapperTypes
Map of primitive to wrapper classes |
static java.lang.String |
SET
|
Constructor Summary | |
---|---|
ReflectionsHelper()
|
Method Summary | ||
---|---|---|
static java.lang.Object |
callMethod(java.lang.Object target,
java.lang.String methodName,
java.lang.Class<?>[] parameterTypes,
java.lang.Object[] args)
|
|
static java.lang.StackTraceElement |
getCaller()
|
|
static java.lang.StackTraceElement |
getCallerNotIn(java.lang.Class<?>... excludedClasses)
|
|
static java.lang.String |
getFieldName(java.lang.String methodName)
|
|
static java.lang.String |
getFirstToUpper(java.lang.String name)
|
|
static java.lang.String |
getGetterMethodName(java.lang.String fieldName)
|
|
static java.util.Set<java.lang.Class<?>> |
getInterfaces(java.lang.Class<?> clazz)
|
|
static java.lang.String |
getSetterMethodName(java.lang.String fieldName)
|
|
static
|
getTypeAnnotations(java.lang.Class<?> clazz,
java.lang.Class<A> annotationClass)
Will search the passed Class as well as all super classes
and interfaces for an Annotation of the passed
annotation Class and return the first appearance. |
|
static void |
inject(java.lang.Object inject,
java.lang.String fieldName,
java.lang.Object value)
A simple injection mechanism, used to slam some mock objects to mimic the JBoss injection system. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.util.Map<java.lang.Class<?>,java.lang.Class<?>> primitivesToWrapperTypes
public static final java.lang.String GET
public static final java.lang.String SET
Constructor Detail |
---|
public ReflectionsHelper()
Method Detail |
---|
public static java.lang.String getGetterMethodName(java.lang.String fieldName)
public static java.lang.String getSetterMethodName(java.lang.String fieldName)
public static java.lang.String getFieldName(java.lang.String methodName)
public static java.lang.String getFirstToUpper(java.lang.String name)
public static void inject(java.lang.Object inject, java.lang.String fieldName, java.lang.Object value) throws java.lang.SecurityException, java.lang.NoSuchFieldException, java.lang.IllegalArgumentException, java.lang.IllegalAccessException
java.lang.SecurityException
java.lang.NoSuchFieldException
java.lang.IllegalArgumentException
java.lang.IllegalAccessException
public static java.lang.Object callMethod(java.lang.Object target, java.lang.String methodName, java.lang.Class<?>[] parameterTypes, java.lang.Object[] args) throws java.lang.SecurityException, java.lang.NoSuchMethodException, java.lang.IllegalArgumentException, java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException
java.lang.SecurityException
java.lang.NoSuchMethodException
java.lang.IllegalArgumentException
java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
public static java.util.Set<java.lang.Class<?>> getInterfaces(java.lang.Class<?> clazz)
Set
of Class
es representing all
interfaces implemented by the passed class of any of its
super classes; never null
.public static <A extends java.lang.annotation.Annotation> A getTypeAnnotations(java.lang.Class<?> clazz, java.lang.Class<A> annotationClass)
Will search the passed Class
as well as all super classes
and interfaces for an Annotation
of the passed
annotation Class
and return the first appearance.
First the passed class will be queried for the annotation,
if nothing is found then its interfaces will be queried
recursively one after another in the ordering returned
by Class.getInterfaces()
and after that,
if not successful yet too, the super class of will
be queried recursively.
NOTE that Annotation
s from interfaces are not
Inherited
!!! Thus this method makes a lot of
sense if you need annotation inheritence both in
super classes as well as interfaces.
A
- clazz
- annotationClass
-
Annotation
of the passed
type found on the passed clazz, its interfaces or super classes,
or null
if not present.public static java.lang.StackTraceElement getCaller()
public static java.lang.StackTraceElement getCallerNotIn(java.lang.Class<?>... excludedClasses)
excludedClasses
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |