public class ReflectionUtils extends Object
| Constructor and Description |
|---|
ReflectionUtils() |
| Modifier and Type | Method and Description |
|---|---|
static <T> Constructor<T> |
findConstructor(Class<T> type,
Class<?>... expectedParams)
Find the first constructor of the given type which matches the expected parameters, which is the one which has
parameters that can be assigned from the expected parameters.
Note: In case the type is a non-static inner class, then all it's constructors have the outer class as the first parameter. Warning: The returned constructor may not be normally visible to the calling class, so use it with care. For example, suppose we have a class A and a class B which extends it: If the class has 2 constructors accepting A and B (respectfully), and we look for one accepting A, then the A constructor is returned. If the class has 2 constructors accepting A and B (respectfully), and we look for one accepting B, then the first matching constructor is returned (not guaranteed to be the same each time). If the class has only a constructor accepting B, and we look for one accepting B, then the B constructor is returned. If the class has only a constructor accepting B, and we look for one accepting A, then null is
returned.
If the class has a default constructor and we don't expect any arguments, then it is returned.
|
static Class<?> |
getClassFor(String className) |
static Annotation |
getColumnAnnotation(Field f)
Get a Field Column annotation
|
static Annotation |
getSizeAnnotation(Field f)
Get a Field Size annotation
|
static Annotation |
getTableAnnotation(Class c) |
public static <T> Constructor<T> findConstructor(Class<T> type, Class<?>... expectedParams)
null is
returned.type - The type to look up the constructor for.expectedParams - The expected parameters for the constructor.null in none found.public static Class<?> getClassFor(String className)
className - The class to load.public static Annotation getTableAnnotation(Class c)
c - the classpublic static Annotation getColumnAnnotation(Field f)
f - the field in the classpublic static Annotation getSizeAnnotation(Field f)
f - Copyright © 2012. All Rights Reserved.