public final class ReflectionUtils extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
ReflectionUtils.FieldWithAnnotation<T extends Annotation>
A field/annotation pair.
|
| Modifier and Type | Method and Description |
|---|---|
static boolean |
equals(Object object1,
Object object2)
Reflection-based implementation of
Object.equals(Object). |
static <T extends Annotation> |
findFieldsWithAnnotation(Class<?> type,
Class<T> annotationType)
Finds fields on the given
type and all of its superclasses
annotated with annotations of type annotationType. |
static List<Method> |
getAccessors(Class<?> clazz)
Gets all accessor methods for the given
clazz. |
static Class<?> |
getFirstParameterizedTypeArgument(Field field)
For a given
field, get its first parameterized type argument. |
static int |
hashCode(Object object)
Reflection-based implementation of
Object.hashCode(). |
static boolean |
isPrimitive(Object object)
Is the given
object a primitive type or wrapper for a primitive
type? |
static String |
toString(Object object)
Reflection-based implementation of
Object.toString(). |
public static boolean isPrimitive(Object object)
object a primitive type or wrapper for a primitive
type?object - The object to check for primitive-ness.true if object is a primitive type or wrapper for a
primitive type, false otherwise.public static <T extends Annotation> List<ReflectionUtils.FieldWithAnnotation<T>> findFieldsWithAnnotation(Class<?> type, Class<T> annotationType)
type and all of its superclasses
annotated with annotations of type annotationType.T - The annotation type.type - The target type token.annotationType - The annotation type token.public static Class<?> getFirstParameterizedTypeArgument(Field field)
field, get its first parameterized type argument.
For example, a field of type List<Long> would have a first type
argument of Long.class.
If the field has no type arguments, null is returned.field - The field to check.null if
none exists.public static List<Method> getAccessors(Class<?> clazz)
clazz.clazz - The class for which accessors are extracted.clazz.public static String toString(Object object)
Object.toString().object - The object to convert to a string representation.object.IllegalStateException - If an error occurs while performing reflection operations.public static int hashCode(Object object)
Object.hashCode().object - The object to hash.object.IllegalStateException - If an error occurs while performing reflection operations.public static boolean equals(Object object1, Object object2)
Object.equals(Object).object1 - One object to compare.object2 - Another object to compare.true if the objects are equal, false otherwise.IllegalStateException - If an error occurs while performing reflection operations.Copyright © 2014. All rights reserved.