T - Parameterized typepublic abstract class TypeOf<T> extends Object
Type information on generic types.
Capture a generic type with an anonymous subclass. For example:
new TypeOf<NamedDomainObjectContainer<ArtifactRepository>>() {}| Modifier | Constructor | Description |
|---|---|---|
protected |
TypeOf() |
| Modifier and Type | Method | Description |
|---|---|---|
boolean |
equals(Object o) |
|
List<TypeOf<?>> |
getActualTypeArguments() |
Returns the list of type arguments used in the construction of this parameterized type.
|
TypeOf<?> |
getComponentType() |
Returns the component type of the array type this object represents.
|
Class<T> |
getConcreteClass() |
This returns the underlying, concrete Java
Class. |
TypeOf<?> |
getLowerBound() |
Returns the first declared lower-bound of the wildcard type expression represented by this type.
|
TypeOf<?> |
getParameterizedTypeDefinition() |
Returns an object that represents the type from which this parameterized type was constructed.
|
String |
getSimpleName() |
Simple name.
|
TypeOf<?> |
getUpperBound() |
Returns the first declared upper-bound of the wildcard type expression represented by this type.
|
int |
hashCode() |
|
boolean |
isArray() |
Queries whether this object represents an array, generic or otherwise.
|
boolean |
isAssignableFrom(Type type) |
Is this type assignable from the given type?
|
boolean |
isAssignableFrom(TypeOf<?> type) |
Is this type assignable from the given type?
|
boolean |
isParameterized() |
Queries whether this object represents a parameterized type.
|
boolean |
isPublic() |
Queries whether the type represented by this object is public (
Modifier.isPublic(int)). |
boolean |
isSimple() |
Queries whether this object represents a simple (non-composite) type, not an array and not a generic type.
|
boolean |
isSynthetic() |
Queries whether this object represents a synthetic type as defined by
Class.isSynthetic(). |
boolean |
isWildcard() |
Queries whether this object represents a wildcard type expression, such as
?, ? extends Number, or ? super Integer. |
static TypeOf<?> |
parameterizedTypeOf(TypeOf<?> parameterizedType,
TypeOf<?>... typeArguments) |
Constructs a new parameterized type from a given parameterized type definition and an array of type arguments.
|
String |
toString() |
|
static <T> TypeOf<T> |
typeOf(Class<T> type) |
Creates an instance of TypeOf for the given Class.
|
static <T> TypeOf<T> |
typeOf(Type type) |
Creates an instance of TypeOf for the given Type.
|
public static <T> TypeOf<T> typeOf(Class<T> type)
T - the parameterized type of the given Classtype - the Classpublic static <T> TypeOf<T> typeOf(Type type)
T - the parameterized type of the given Typetype - the Typepublic static TypeOf<?> parameterizedTypeOf(TypeOf<?> parameterizedType, TypeOf<?>... typeArguments)
parameterizedTypeOf(new TypeOf<List<?>>() {}, new TypeOf<String>() {}) is equivalent to
new TypeOf<List<String>>() {}, except both the parameterized type definition and type arguments can be dynamically computed.parameterizedType - the parameterized type from which to construct the new parameterized typetypeArguments - the arguments with which to construct the new parameterized typeisParameterized()public boolean isSimple()
public boolean isSynthetic()
Class.isSynthetic().public boolean isPublic()
Modifier.isPublic(int)).Modifier.isPublic(int),
Class.getModifiers()public boolean isArray()
getComponentType()@Nullable public TypeOf<?> getComponentType()
isArray()public boolean isParameterized()
getParameterizedTypeDefinition(),
getActualTypeArguments()public TypeOf<?> getParameterizedTypeDefinition()
isParameterized()public List<TypeOf<?>> getActualTypeArguments()
isParameterized()public boolean isWildcard()
?, ? extends Number, or ? super Integer.getUpperBound()@Nullable public TypeOf<?> getUpperBound()
@Nullable public TypeOf<?> getLowerBound()
public final boolean isAssignableFrom(TypeOf<?> type)
type - the given typepublic final boolean isAssignableFrom(Type type)
type - the given typepublic String getSimpleName()
public Class<T> getConcreteClass()
This returns the underlying, concrete Java Class.
For example, a simple TypeOf<String> will be the given generic type String.class.
Generic types like TypeOf<List<String>> would have the concrete type of List.class.
For array types like TypeOf<String[]>, the concrete type will be an array of the component type (String[].class).