T
- Parameterized type@Incubating public 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 and Description |
---|---|
protected |
TypeOf() |
Modifier and Type | Method and 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.
|
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()
public final boolean isAssignableFrom(TypeOf<?> type)
type
- the given typepublic final boolean isAssignableFrom(Type type)
type
- the given typepublic String getSimpleName()