Interface TypeReference
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description booleanequals(java.lang.Object obj)Checks whether this type reference equals the given type reference.java.util.List<TypeReference>getActualTypeArguments()java.lang.Iterable<? extends ResolvedMethod>getAllResolvedMethods()Computes all the resolved methods that can be called on this type, either because they were declared directly by the type or by one of its supertypes.TypeReferencegetArrayComponentType()java.lang.Iterable<? extends ResolvedConstructor>getDeclaredResolvedConstructors()java.lang.Iterable<? extends ResolvedMethod>getDeclaredResolvedMethods()java.lang.Iterable<? extends TypeReference>getDeclaredSuperTypes()TypeReferencegetLowerBound()java.lang.StringgetName()returns the text representation using the qualified names of the involved types.TypeReferencegetPrimitiveIfWrapper()java.lang.StringgetSimpleName()Returns a text representation using the simple names of the involved types.TypegetType()TypeReferencegetUpperBound()TypeReferencegetWrapperIfPrimitive()inthashCode()booleanisAnyType()booleanisArray()booleanisAssignableFrom(TypeReference typeReference)Determines if the specifiedTypeReferenceparameter can be assigned to thisTypeReference.booleanisInferred()Whether the given type reference is an inferred reference.booleanisPrimitive()booleanisVoid()booleanisWildCard()booleanisWrapper()Checks whether this type is one of the wrapper types for the primitive value types.java.lang.StringtoString()A string representation for this type reference.
-
-
-
Method Detail
-
getSimpleName
java.lang.String getSimpleName()
Returns a text representation using the simple names of the involved types. I.e. for 'java.util.List<? extends java.math.BigDecimal>' this method returns 'List<? extends BigDecimal>'- Returns:
- the simple name of this type reference
-
getName
java.lang.String getName()
returns the text representation using the qualified names of the involved types.- Returns:
- the qualified name of this type reference
-
getType
Type getType()
- Returns:
- the referenced type.
-
getActualTypeArguments
java.util.List<TypeReference> getActualTypeArguments()
- Returns:
- the type arguments
-
isWildCard
boolean isWildCard()
- Returns:
- whether this is a wildcard reference
-
getUpperBound
TypeReference getUpperBound()
- Returns:
- the upper bounds
-
getLowerBound
TypeReference getLowerBound()
- Returns:
- the lower bounds
-
isArray
boolean isArray()
- Returns:
- whether this is an array
-
getArrayComponentType
TypeReference getArrayComponentType()
- Returns:
- the component type if this tye reference is an array type reference,
nullotherwise.
-
isAnyType
boolean isAnyType()
- Returns:
- whether this is the any type, The any type is the subtype of every reference type and its only instance is
null.
-
isPrimitive
boolean isPrimitive()
- Returns:
- whether this is a primitive type (i.e. one of boolean, char, byte, short, int, long, float, double).
-
getWrapperIfPrimitive
TypeReference getWrapperIfPrimitive()
- Returns:
- the corresponding wrapper
TypeReferenceif this type references is a primitive type. Returnsthisotherwise.
-
isWrapper
boolean isWrapper()
Checks whether this type is one of the wrapper types for the primitive value types.- Returns:
- wither this is one of the wrapper types for the primitive value types.
-
getPrimitiveIfWrapper
TypeReference getPrimitiveIfWrapper()
- Returns:
- the corresponding primitive
TypeReferenceif this type references is a wrapper type. Returnsthisotherwise.
-
isVoid
boolean isVoid()
- Returns:
- whether this type is 'void' (doesn't include 'java.lang.Void')
-
isAssignableFrom
boolean isAssignableFrom(TypeReference typeReference)
Determines if the specifiedTypeReferenceparameter can be assigned to thisTypeReference. It returnstrueif so; otherwise it returnsfalse.- Parameters:
typeReference-- Returns:
- returns
trueis the specified type reference parameter can be assigned to this type reference.
-
isInferred
boolean isInferred()
Whether the given type reference is an inferred reference. That is the type is to be computed from some Expression, e.g. a method body or a field initializer. Inferred type references can only be used as handles, and will through anUnsupportedOperationExceptionon every method other than- Returns:
- whether this type reference is an inferred type reference.
-
getDeclaredSuperTypes
java.lang.Iterable<? extends TypeReference> getDeclaredSuperTypes()
- Returns:
- the supertypes (superclass and interfaces) directly implemented/extended by this type
- Since:
- 2.7
-
getDeclaredResolvedMethods
java.lang.Iterable<? extends ResolvedMethod> getDeclaredResolvedMethods()
- Returns:
- the resolved methods directly declared by this type
- Since:
- 2.7
-
getDeclaredResolvedConstructors
java.lang.Iterable<? extends ResolvedConstructor> getDeclaredResolvedConstructors()
- Returns:
- the resolved constructors directly declared by this type
- Since:
- 2.7
-
getAllResolvedMethods
java.lang.Iterable<? extends ResolvedMethod> getAllResolvedMethods()
Computes all the resolved methods that can be called on this type, either because they were declared directly by the type or by one of its supertypes. For overloaded methods, the one declared closest to this type is used. E.g. when called on the classCin this hierarchy:class A { def CharSequence foo() } class B extends A { override String foo() } class C extends B {}B#foo() would be contained, but not A#foo().
- Returns:
- the resolved methods declared in this type and its supertypes.
- Since:
- 2.7
-
equals
boolean equals(java.lang.Object obj)
Checks whether this type reference equals the given type reference. For type References whereisInferred()istrue, the implementation is based on identity of the underlying AST.- Overrides:
equalsin classjava.lang.Object- Parameters:
obj-- Returns:
- whether the given obj is the same instance
- Since:
- 2.7
-
hashCode
int hashCode()
- Overrides:
hashCodein classjava.lang.Object- Since:
- 2.7
-
toString
java.lang.String toString()
A string representation for this type reference. If this reference is resolved, it will return the simple name of this reference. Otherwise a technical information about the inferred type reference.- Overrides:
toStringin classjava.lang.Object- Returns:
- a string representation
- Since:
- 2.8
-
-