|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.beanfabrics.util.GenericType
public class GenericType
The GenericType
is a facade for a Type
object representing a
Java class. It provides convenient functions for generic type reflection.
Constructor Summary | |
---|---|
GenericType(java.lang.Class<?> cls)
Creates a GenericType for the given Class . |
Method Summary | |
---|---|
java.lang.Class<?> |
asClass()
Returns the class that this type represents. |
GenericType |
getFieldType(java.lang.String fieldname)
Returns the type of the field with the given name as a GenericType . |
GenericType |
getMethodReturnType(java.lang.String methodName)
Returns the return type of the method with the given name (having no parameters) as a GenericType . |
java.lang.reflect.Type |
getType()
Returns the type represented by this GenericType . |
GenericType |
getTypeParameter(java.lang.reflect.TypeVariable<? extends java.lang.Class<?>> variable)
Returns the value of the given TypeVariable as a
GenericType . |
boolean |
isClass()
Returns true if this type represents a Class . |
boolean |
isParameterizedType()
Returns true if this type represents a
ParameterizedType . |
boolean |
isTypeVariable()
Returns true if this type represents a TypeVariable . |
boolean |
isWildcardType()
Returns true if this type represents a WildcardType . |
java.lang.reflect.Type |
narrow(java.lang.reflect.Type aType,
java.lang.Class<?> targetType)
|
java.lang.reflect.Type |
tryResolve(java.lang.reflect.Type type)
|
java.lang.reflect.Type |
tryResolve(java.lang.reflect.TypeVariable<?> var)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public GenericType(java.lang.Class<?> cls)
GenericType
for the given Class
.
cls
- Method Detail |
---|
public java.lang.reflect.Type getType()
GenericType
. This can be one
of Class
, ParameterizedType
, and TypeVariable
.
GenericType
.public boolean isTypeVariable()
true
if this type represents a TypeVariable
.
true
if this type represents a TypeVariable
public boolean isClass()
true
if this type represents a Class
.
true
if this type represents a Class
public java.lang.Class<?> asClass() throws java.lang.IllegalStateException
java.lang.IllegalStateException
- if this type does not represent a classpublic boolean isParameterizedType()
true
if this type represents a
ParameterizedType
.
true
if this type represents a
ParameterizedType
public boolean isWildcardType()
true
if this type represents a WildcardType
.
true
if this type represents a WildcardType
public GenericType getTypeParameter(java.lang.reflect.TypeVariable<? extends java.lang.Class<?>> variable) throws java.lang.IllegalArgumentException, java.lang.IllegalStateException
TypeVariable
as a
GenericType
.
variable
- must parameterize this type or one of it's super types
TypeVariable
as a
GenericType
java.lang.IllegalArgumentException
- if the variable does not parameterize this type
java.lang.UnsupportedOperationException
- if the type parameter resolution is not supported for this
type
java.lang.IllegalStateException
public GenericType getFieldType(java.lang.String fieldname)
GenericType
.
fieldname
- must denote a field in this type or one of it's super types.
GenericType
java.lang.UnsupportedOperationException
- if field type resolution is not supported for this typepublic GenericType getMethodReturnType(java.lang.String methodName)
GenericType
.
Please note:
Only methods without parameters are supported right now!
methodName
-
GenericType
.
java.lang.UnsupportedOperationException
- if method return type resolution is not supported for this
typepublic java.lang.reflect.Type tryResolve(java.lang.reflect.Type type)
public java.lang.reflect.Type tryResolve(java.lang.reflect.TypeVariable<?> var)
public java.lang.reflect.Type narrow(java.lang.reflect.Type aType, java.lang.Class<?> targetType)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |