public class ReflectionUtilities extends Object
Modifier and Type | Field and Description |
---|---|
static String |
regexp
This is used to split Java classnames.
|
Constructor and Description |
---|
ReflectionUtilities() |
Modifier and Type | Method and Description |
---|---|
static Class<?> |
boxClass(Class<?> c)
Given a primitive type, return its boxed representation.
|
static Iterable<Type> |
classAndAncestors(Type c)
Given a Type, return all of the classes it extends and interfaces it implements (including the class itself).
|
static Class<?> |
classForName(String name,
ClassLoader loader)
Lookup the provided name using the provided classloader.
|
static String |
getFullName(Field f)
Return the full name of the provided field.
|
static String |
getFullName(Type name)
Return the full name of the raw type of the provided Type.
|
static Type |
getInterfaceTarget(Class<?> iface,
Type type)
This method takes a class called clazz that *directly* implements a generic interface or generic class, iface.
|
static Type |
getNamedParameterTargetOrNull(Class<?> clazz) |
static Class<?> |
getRawClass(Type clazz)
Coerce a Type into a Class.
|
static String |
getSimpleName(Type name)
Get the simple name of the class.
|
static boolean |
isCoercable(Class<?> to,
Class<?> from)
Check to see if one class can be coerced into another.
|
public static final String regexp
public ReflectionUtilities()
public static Class<?> boxClass(Class<?> c)
c
- The class to be boxed.public static Iterable<Type> classAndAncestors(Type c)
public static boolean isCoercable(Class<?> to, Class<?> from)
public static Class<?> classForName(String name, ClassLoader loader) throws ClassNotFoundException
ClassNotFoundException
public static String getSimpleName(Type name)
name
- public static String getFullName(Type name)
name
- public static String getFullName(Field f)
public static Type getInterfaceTarget(Class<?> iface, Type type) throws IllegalArgumentException
iface
- A generic interface; we're looking up it's first (and only) parameter.type
- A type that is more specific than clazz, or clazz if no such type is available.IllegalArgumentException
- if clazz does not directly implement iface.public static Type getNamedParameterTargetOrNull(Class<?> clazz) throws ClassHierarchyException
clazz
- BindException
- If clazz's definition incorrectly uses Name or @NamedParameterClassHierarchyException
public static Class<?> getRawClass(Type clazz)
Copyright © 2015 The Apache Software Foundation. All rights reserved.