public class ReflectHelper extends Object
| Constructor and Description |
|---|
ReflectHelper() |
| Modifier and Type | Method and Description |
|---|---|
static Number |
convertNumber(Number value,
Class<?> numberType)
Converts the number into number Type
|
static ConstructorAccessor |
createConstructor(Constructor<?> constructor)
Creates and returns a fast constructor accessor.
|
static String |
createMemberName(Member member)
Returns the qualified name for the member.
|
static AbstractAccessor |
getAccessor(Member javaMember)
Returns the accessor for the member
|
static <T> Class<T> |
getActualType(Class<?> clazz,
String attributeName,
Class<?> originalType)
Returns the actual type of the attribute, resolving generic types if necessary.
|
static <A extends Annotation> |
getAnnotation(Member member,
Class<A> annotation)
Returns the annotation instance if the
member has the annotation. |
static <X> Class<X> |
getGenericType(Member member,
int index)
Returns the actual generic type of a class's type parameter of the
member. |
static Class<?> |
getMemberType(Member member)
Returns the type class of the
member. |
static PropertyDescriptor[] |
getProperties(Class<?> clazz)
Returns the property descriptors for the class.
|
static boolean |
isCollection(Class<?> type)
Returns if the
type is a collection type. |
static void |
setAccessible(Member member,
boolean accessible)
Sets the member's accessibility status.
|
static void |
warnAnnotations(BLogger logger,
Member member,
Set<Class<? extends Annotation>> annotations)
Logs warnings for annotations that were ignored.
|
public static Number convertNumber(Number value, Class<?> numberType)
value - the number valuenumberType - the number typepublic static ConstructorAccessor createConstructor(Constructor<?> constructor)
constructor - the original constructorpublic static String createMemberName(Member member)
member - the member to qualifypublic static AbstractAccessor getAccessor(Member javaMember)
javaMember - the java memberpublic static <T> Class<T> getActualType(Class<?> clazz, String attributeName, Class<?> originalType)
T - the xpected typeclazz - the actual classattributeName - the name of the attributeoriginalType - th original type of the attributepublic static <A extends Annotation> A getAnnotation(Member member, Class<A> annotation)
member has the annotation.A - the class of annotationmember - the memberannotation - the type of the annotation instance to returnannotation instance if the member has the annotation or nullpublic static <X> Class<X> getGenericType(Member member, int index)
member.
if the member is a field then field's generic types are checked. Otherwise the member is treated a a method
and its return type's is checked.
X - the type of the classmember - the memberindex - the index number of the generic parameterpublic static Class<?> getMemberType(Member member)
member.member - the membermember's type as java classpublic static PropertyDescriptor[] getProperties(Class<?> clazz)
clazz - the classpublic static boolean isCollection(Class<?> type)
type is a collection type.
Note that this method uses equality, not assignability to test.
type - the type to check if it is collectiontype is a collection type, false otherwisepublic static void setAccessible(Member member, boolean accessible)
member - the member of which to set accessibility statusaccessible - true to set accessible, false to make it not accessiblepublic static void warnAnnotations(BLogger logger, Member member, Set<Class<? extends Annotation>> annotations)
logger - the logger to log the warnings.member - the memberannotations - the set of annotations allowedCopyright © 2012-2013 Batoo. All Rights Reserved.