Navigator implementation for java.lang.reflect.
| Modifier and Type | Class and Description |
|---|---|
| private static class |
| Modifier and Type | Field and Description |
|---|---|
| private static final TypeVisitor | |
| private static final TypeVisitor | |
| private static final TypeVisitor | eraser
Implements the logic for |
| private static final ReflectionNavigator |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public Class | asDecl(Type t)
Implements org. If the given type is an use of class declaration,
returns the type casted as |
| public Class | asDecl(Class<?> c)
Implements org. Gets the |
| public Type | createParameterizedType(Class<?> rawType, Type... arguments)
Returns the |
| public <T> Class | erasure(Type t)
Implements org. Returns the runtime representation of the given type. |
| private Type | |
| public Type | getBaseClass(Type t, Class<?> sup)
Implements org. Gets the parameterization of the given base type. |
| public Location | getClassLocation(final Class<?> clazz)
Implements org. Returns a location of the specified class. |
| public String | getClassName(Class<?> clazz)
Implements org. Gets the fully-qualified name of the class. |
| public String | getClassShortName(Class<?> clazz)
Implements org. Gets the short name of the class ("Object" for |
| public Type | getComponentType(Type t)
Implements org. Gets the component type of the array. |
| public Field | getDeclaredField(final Class<?> clazz, final String fieldName)
Implements org. Gets the named field declared on the given class. |
| public Collection | getDeclaredFields(final Class<?> clazz)
Implements org. Gets all the declared fields of the given class. |
| public Collection | getDeclaredMethods(final Class<?> clazz)
Implements org. Gets all the declared methods of the given class (regardless of their access modifiers, regardless of whether they override methods of the base classes.) Note that this method does not list methods declared on base classes. |
| public Class | getDeclaringClassForField(Field field)
Implements org. Gets the class that declares the given field. |
| public Class | getDeclaringClassForMethod(Method method)
Implements org. Gets the class that declares the given method. |
| public Field[] | getEnumConstants(Class<?> clazz)
Implements org. Gets the enumeration constants from an enum class. |
| public Location | getFieldLocation(final Field field)
Implements org.
|
| public String | getFieldName(Field field)
Implements org. Gets the name of the field. |
| public Type | getFieldType(Field field)
Implements org. Gets the type of the field. |
| pack-priv static ReflectionNavigator | |
| public Location | getMethodLocation(final Method method)
Implements org.
|
| public String | getMethodName(Method method)
Implements org. Gets the name of the method, such as "toString" or "equals". |
| public Type[] | getMethodParameters(Method method)
Implements org. Returns the list of parameters to the method. |
| public String | getPackageName(Class<?> clazz)
Implements org. Gets the package name of the given class. |
| public Type | getPrimitive(Class<?> primitiveType)
Implements org. Returns the representation for the given primitive type. |
| public Type | getReturnType(Method method)
Implements org. Gets the return type of a method. |
| public Class | getSuperClass(Class<?> clazz)
Implements org. Gets the base class of the specified class. |
| public Type | getTypeArgument(Type type, int i)
Implements org. Gets the i-th type argument from a parameterized type. |
| public String | getTypeName(Type type)
Implements org. Gets the display name of the type object |
| public Type | getVoidType()
Implements org. Gets the representation of the primitive "void" type. |
| public boolean | hasDefaultConstructor(Class<?> c)
Implements org. Returns true if the given class has a no-arg default constructor. |
| public boolean | isAbstract(Class<?> clazz)
Implements org. Returns true if this is an abstract class. |
| public boolean | isArray(Type t)
Implements org. Checks if the type is an array type. |
| public boolean | isArrayButNotByteArray(Type t)
Implements org. Checks if the type is an array type but not byte[]. |
| public boolean | isBridgeMethod(Method method)
Implements org. Returns true if this method is a bridge method as defined in JLS. |
| public boolean | isEnum(Class<?> c)
Implements org. Returns true if this is an enum class. |
| public boolean | isFinal(Class<?> clazz)
Implements org. Returns true if this is a final class. |
| public boolean | isFinalMethod(Method method)
Implements org. Returns true if the method is final. |
| public boolean | isInnerClass(Class<?> clazz)
Implements org. Returns true if the given class is an inner class. |
| public boolean | isInterface(Class<?> clazz)
Implements org. Returns true if 'clazz' is an interface. |
| public boolean | isOverriding(Method method, final Class<?> base)
Implements org. Returns true if the given method is overriding another one defined in the base class 'base' or its ancestors. |
| public boolean | isParameterizedType(Type type)
Implements org. Returns true if t is a parameterized type. |
| public boolean | isPrimitive(Type type)
Implements org. Checks if the given type is a primitive type. |
| public boolean | isPublicField(Field field)
Implements org. Returns true if the field is public. |
| public boolean | isPublicMethod(Method method)
Implements org. Returns true if the method is public. |
| public boolean | isSameType(Type t1, Type t2)
Implements org. Checks if types are the same |
| public boolean | isStaticField(Field field)
Implements org. Returns true if the field is static. |
| public boolean | isStaticMethod(Method method)
Implements org. Returns true if the method is static. |
| public boolean | isSubClassOf(Type sub, Type sup)
Implements org. Checks if |
| public boolean | isTransient(Field f)
Implements org. Returns true if the field is transient. |
| public Class | loadObjectFactory(Class<?> referencePoint, String pkg)
Implements org. Finds ObjectFactory for the given referencePoint. |
| public Class | ref(Class<?> c)
Implements org. Gets the representation of the given Java type in |
| public Class | use(Class<?> c)
Implements org. Gets the T for the given C. |
| baseClassFinder | back to summary |
|---|---|
| private static final TypeVisitor<Type, Class<?>> baseClassFinder | |
| binder | back to summary |
|---|---|
| private static final TypeVisitor<Type, ReflectionNavigator. | |
| eraser | back to summary |
|---|---|
| private static final TypeVisitor<Class<T>, Void> eraser Implements the logic for | |
| INSTANCE | back to summary |
|---|---|
| private static final ReflectionNavigator INSTANCE | |
| ReflectionNavigator | back to summary |
|---|---|
| private ReflectionNavigator() | |
| asDecl | back to summary |
|---|---|
| public Class Implements org. Doc from org. If the given type is an use of class declaration,
returns the type casted as Todo define the exact semantics.
| |
| asDecl | back to summary |
|---|---|
| public Class Implements org. Doc from org. Gets the
| |
| createParameterizedType | back to summary |
|---|---|
| public Type createParameterizedType(Class<?> rawType, Type... arguments) Returns the | |
| erasure | back to summary |
|---|---|
| public <T> Class Implements org. Returns the runtime representation of the given type. This corresponds to the notion of the erasure in JSR-14.
Because of the difference in the way Annotation Processing and the Java reflection
treats primitive type and array type, we can't define this method
on It made me realize how difficult it is to define the common navigation layer for two different underlying reflection library. The other way is to throw away the entire parameterization and go to the wrapper approach.
| |
| fix | back to summary |
|---|---|
| private Type fix(Type t) JDK 5.0 has a bug of creating | |
| getBaseClass | back to summary |
|---|---|
| public Type getBaseClass(Type t, Class<?> sup) Implements org. Doc from org. Gets the parameterization of the given base type. For example, given the following
This method works like this:
| |
| getClassLocation | back to summary |
|---|---|
| public Location getClassLocation(final Class<?> clazz) Implements org. Doc from org. Returns a location of the specified class.
| |
| getClassName | back to summary |
|---|---|
| public String getClassName(Class<?> clazz) Implements org. Doc from org. Gets the fully-qualified name of the class.
("java.lang.Object" for
| |
| getClassShortName | back to summary |
|---|---|
| public String getClassShortName(Class<?> clazz) Implements org. Doc from org. Gets the short name of the class ("Object" for
| |
| getComponentType | back to summary |
|---|---|
| public Type getComponentType(Type t) Implements org. Doc from org. Gets the component type of the array.
| |
| getDeclaredField | back to summary |
|---|---|
| public Field getDeclaredField(final Class<?> clazz, final String fieldName) Implements org. Doc from org. Gets the named field declared on the given class. This method doesn't visit ancestors, but does recognize non-public fields.
| |
| getDeclaredFields | back to summary |
|---|---|
| public Collection Implements org. Doc from org. Gets all the declared fields of the given class.
| |
| getDeclaredMethods | back to summary |
|---|---|
| public Collection Implements org. Doc from org. Gets all the declared methods of the given class (regardless of their access modifiers, regardless of whether they override methods of the base classes.) Note that this method does not list methods declared on base classes.
| |
| getDeclaringClassForField | back to summary |
|---|---|
| public Class Implements org. Doc from org. Gets the class that declares the given field.
| |
| getDeclaringClassForMethod | back to summary |
|---|---|
| public Class Implements org. Doc from org. Gets the class that declares the given method.
| |
| getEnumConstants | back to summary |
|---|---|
| public Field[] getEnumConstants(Class<?> clazz) Implements org. Doc from org. Gets the enumeration constants from an enum class.
| |
| getFieldLocation | back to summary |
|---|---|
| public Location getFieldLocation(final Field field) Implements org.
| |
| getFieldName | back to summary |
|---|---|
| public String getFieldName(Field field) Implements org. Doc from org. Gets the name of the field.
| |
| getFieldType | back to summary |
|---|---|
| public Type getFieldType(Field field) Implements org. Doc from org. Gets the type of the field.
| |
| getInstance | back to summary |
|---|---|
| pack-priv static ReflectionNavigator getInstance() | |
| getMethodLocation | back to summary |
|---|---|
| public Location getMethodLocation(final Method method) Implements org.
| |
| getMethodName | back to summary |
|---|---|
| public String getMethodName(Method method) Implements org. Doc from org. Gets the name of the method, such as "toString" or "equals".
| |
| getMethodParameters | back to summary |
|---|---|
| public Type[] getMethodParameters(Method method) Implements org. Doc from org. Returns the list of parameters to the method.
| |
| getPackageName | back to summary |
|---|---|
| public String getPackageName(Class<?> clazz) Implements org. Doc from org. Gets the package name of the given class.
| |
| getPrimitive | back to summary |
|---|---|
| public Type getPrimitive(Class<?> primitiveType) Implements org. Doc from org. Returns the representation for the given primitive type.
| |
| getReturnType | back to summary |
|---|---|
| public Type getReturnType(Method method) Implements org. Doc from org. Gets the return type of a method.
| |
| getSuperClass | back to summary |
|---|---|
| public Class Implements org. Doc from org. Gets the base class of the specified class.
| |
| getTypeArgument | back to summary |
|---|---|
| public Type getTypeArgument(Type type, int i) Implements org. Doc from org. Gets the i-th type argument from a parameterized type.
For example,
| |
| getTypeName | back to summary |
|---|---|
| public String getTypeName(Type type) Implements org. Doc from org. Gets the display name of the type object
| |
| getVoidType | back to summary |
|---|---|
| public Type getVoidType() Implements org. Doc from org. Gets the representation of the primitive "void" type.
| |
| hasDefaultConstructor | back to summary |
|---|---|
| public boolean hasDefaultConstructor(Class<?> c) Implements org. Doc from org. Returns true if the given class has a no-arg default constructor. The constructor does not need to be public.
| |
| isAbstract | back to summary |
|---|---|
| public boolean isAbstract(Class<?> clazz) Implements org. Doc from org. Returns true if this is an abstract class.
| |
| isArray | back to summary |
|---|---|
| public boolean isArray(Type t) Implements org. Doc from org. Checks if the type is an array type.
| |
| isArrayButNotByteArray | back to summary |
|---|---|
| public boolean isArrayButNotByteArray(Type t) Implements org. Doc from org. Checks if the type is an array type but not byte[].
| |
| isBridgeMethod | back to summary |
|---|---|
| public boolean isBridgeMethod(Method method) Implements org. Doc from org. Returns true if this method is a bridge method as defined in JLS.
| |
| isEnum | back to summary |
|---|---|
| public boolean isEnum(Class<?> c) Implements org. Doc from org. Returns true if this is an enum class.
| |
| isFinal | back to summary |
|---|---|
| public boolean isFinal(Class<?> clazz) Implements org. Doc from org. Returns true if this is a final class.
| |
| isFinalMethod | back to summary |
|---|---|
| public boolean isFinalMethod(Method method) Implements org. Doc from org. Returns true if the method is final.
| |
| isInnerClass | back to summary |
|---|---|
| public boolean isInnerClass(Class<?> clazz) Implements org. Doc from org. Returns true if the given class is an inner class. This is only used to improve the error diagnostics, so it's OK to fail to detect some inner classes as such. Note that this method should return false for nested classes (static classes.)
| |
| isInterface | back to summary |
|---|---|
| public boolean isInterface(Class<?> clazz) Implements org. Doc from org. Returns true if 'clazz' is an interface.
| |
| isOverriding | back to summary |
|---|---|
| public boolean isOverriding(Method method, final Class<?> base) Implements org. Doc from org. Returns true if the given method is overriding another one defined in the base class 'base' or its ancestors.
| |
| isParameterizedType | back to summary |
|---|---|
| public boolean isParameterizedType(Type type) Implements org. Doc from org. Returns true if t is a parameterized type.
| |
| isPrimitive | back to summary |
|---|---|
| public boolean isPrimitive(Type type) Implements org. Doc from org. Checks if the given type is a primitive type.
| |
| isPublicField | back to summary |
|---|---|
| public boolean isPublicField(Field field) Implements org. Doc from org. Returns true if the field is public.
| |
| isPublicMethod | back to summary |
|---|---|
| public boolean isPublicMethod(Method method) Implements org. Doc from org. Returns true if the method is public.
| |
| isSameType | back to summary |
|---|---|
| public boolean isSameType(Type t1, Type t2) Implements org. Doc from org. Checks if types are the same
| |
| isStaticField | back to summary |
|---|---|
| public boolean isStaticField(Field field) Implements org. Doc from org. Returns true if the field is static.
| |
| isStaticMethod | back to summary |
|---|---|
| public boolean isStaticMethod(Method method) Implements org. Doc from org. Returns true if the method is static.
| |
| isSubClassOf | back to summary |
|---|---|
| public boolean isSubClassOf(Type sub, Type sup) Implements org. Doc from org. Checks if Todo should this method take T or C?
| |
| isTransient | back to summary |
|---|---|
| public boolean isTransient(Field f) Implements org. Doc from org. Returns true if the field is transient.
| |
| loadObjectFactory | back to summary |
|---|---|
| public Class Implements org. Doc from org. Finds ObjectFactory for the given referencePoint.
| |
| ref | back to summary |
|---|---|
| public Class Implements org. Doc from org. Gets the representation of the given Java type in
| |
| use | back to summary |
|---|---|
| public Class Implements org. Doc from org. Gets the T for the given C.
| |