@NonNullByDefault public class ParameterizedTypeReference extends LightweightTypeReference
LightweightTypeReference.IdentifierFunction, LightweightTypeReference.JavaIdentifierFunction, LightweightTypeReference.SimpleNameFunction, LightweightTypeReference.UniqueIdentifierFunction| Modifier and Type | Field and Description |
|---|---|
protected boolean |
resolved |
KIND_ANY_TYPE_REFERENCE, KIND_ARRAY_TYPE_REFERENCE, KIND_COMPOUND_TYPE_REFERENCE, KIND_FUNCTION_TYPE_REFERENCE, KIND_LIGHTWEIGHT_TYPE_REFERENCE, KIND_PARAMETERIZED_TYPE_REFERENCE, KIND_UNBOUND_TYPE_REFERENCE, KIND_UNKNOWN_TYPE_REFERENCE, KIND_WILDCARD_TYPE_REFERENCE| Constructor and Description |
|---|
ParameterizedTypeReference(ITypeReferenceOwner owner,
JvmType type) |
| Modifier and Type | Method and Description |
|---|---|
void |
accept(TypeReferenceVisitor visitor) |
<Param> void |
accept(TypeReferenceVisitorWithParameter<Param> visitor,
Param param) |
<Param,Result> |
accept(TypeReferenceVisitorWithParameterAndResult<Param,Result> visitor,
Param param) |
<Result> Result |
accept(TypeReferenceVisitorWithResult<Result> visitor) |
void |
addTypeArgument(LightweightTypeReference argument) |
protected void |
copyTypeArguments(ParameterizedTypeReference result,
ITypeReferenceOwner owner) |
protected ParameterizedTypeReference |
doCopyInto(ITypeReferenceOwner owner) |
FunctionTypeReference |
getAsFunctionTypeReference()
Returns the equivalent
FunctionTypeReference if this reference
points to a function or procedure
or if it is already a function type reference. |
protected java.lang.String |
getAsString(java.lang.String type,
com.google.common.base.Function<LightweightTypeReference,java.lang.String> format) |
FunctionTypeKind |
getFunctionTypeKind() |
java.lang.String |
getIdentifier() |
java.lang.String |
getJavaIdentifier() |
int |
getKind()
Subclasses must override this method.
|
LightweightTypeReference |
getPrimitiveIfWrapperType() |
Primitives.Primitive |
getPrimitiveKind() |
Primitives.Primitive |
getPrimitiveKindIfWrapperType() |
LightweightTypeReference |
getRawSuperType(JvmType rawType) |
LightweightTypeReference |
getRawTypeReference() |
java.util.List<JvmType> |
getRawTypes() |
java.lang.String |
getSimpleName() |
LightweightTypeReference |
getSuperType(java.lang.Class<?> rawType)
Returns the resolved super type for the given raw type or
null if the raw type
is not a valid super type of this type. |
LightweightTypeReference |
getSuperType(JvmType rawType)
Returns the resolved super type for the given raw type or null if the raw type
is not a valid super type of this type.
|
protected java.util.List<LightweightTypeReference> |
getSuperTypes(TypeParameterSubstitutor<?> substitutor) |
JvmType |
getType() |
java.util.List<LightweightTypeReference> |
getTypeArguments()
Returns the type arguments of this reference if it has any.
|
java.lang.String |
getUniqueIdentifier()
Returns an identifier that allows to disambiguate type parameter names that have
different origins.
|
LightweightTypeReference |
getWrapperTypeIfPrimitive() |
boolean |
isInterfaceType() |
boolean |
isOwnedBy(ITypeReferenceOwner owner) |
boolean |
isPrimitive() |
boolean |
isPrimitiveVoid() |
boolean |
isRawType()
Returns
true is this type points to a raw type. |
boolean |
isResolved() |
boolean |
isType(java.lang.Class<?> clazz)
Returns true if this type reference represents an type with the given
raw type
clazz. |
protected boolean |
isTypeVisible(IVisibilityHelper visibilityHelper) |
boolean |
isVisible(IVisibilityHelper visibilityHelper)
Returns
true if this type is fully visible according to the given visibilityHelper. |
boolean |
isWrapper() |
ParameterizedTypeReference |
toInstanceTypeReference()
Returns a projection of this type to the instance level.
|
JvmTypeReference |
toJavaCompliantTypeReference(IVisibilityHelper visibilityHelper)
Converts this type reference to a
JvmTypeReference that can
be used in Java source code. |
JvmTypeReference |
toTypeReference() |
ArrayTypeReference |
tryConvertToArray()
Returns the array representation of this reference if its represents a subtype of
Iterable
or already an array itself. |
FunctionTypeReference |
tryConvertToFunctionTypeReference(boolean rawType)
Converts this reference to a
FunctionTypeReference if the referenced type is a SAM type. |
LightweightTypeReference |
tryConvertToListType()
Returns the list representation of this reference if it represents an array or is
already a subtype of
List. |
accept, accept, collectSuperTypes, collectSuperTypes, copyInto, createSubstitutor, expose, findNonNullType, findType, getAllSuperTypes, getComponentType, getInvariantBoundSubstitute, getLowerBoundSubstitute, getMultiTypeComponents, getNonInterfaceTypes, getOwner, getServices, getSuperTypes, getTypesFactory, getUniqueIdentifier, getUpperBoundSubstitute, internalFindTopLevelType, internalIsAssignableFrom, isAny, isArray, isAssignableFrom, isAssignableFrom, isAssignableFrom, isAssignableFrom, isFunctionType, isMultiType, isSubtypeOf, isSubtypeOf, isSynonym, isUnknown, isValidHint, isWildcard, toJavaCompliantTypeReference, toJavaCompliantTypeReference, toJavaType, toMultiType, toStringpublic ParameterizedTypeReference(ITypeReferenceOwner owner, JvmType type)
public int getKind()
getKind in class LightweightTypeReferencepublic JvmTypeReference toTypeReference()
toTypeReference in class LightweightTypeReferencepublic LightweightTypeReference getRawTypeReference()
getRawTypeReference in class LightweightTypeReferencepublic java.util.List<JvmType> getRawTypes()
getRawTypes in class LightweightTypeReferenceprotected boolean isTypeVisible(IVisibilityHelper visibilityHelper)
public boolean isVisible(IVisibilityHelper visibilityHelper)
LightweightTypeReferencetrue if this type is fully visible according to the given visibilityHelper.
All components and bounds are taken into account, e.g.
arrays use their component type
and generified types check their type arguments, too.isVisible in class LightweightTypeReferencepublic JvmTypeReference toJavaCompliantTypeReference(IVisibilityHelper visibilityHelper)
LightweightTypeReferenceJvmTypeReference that can
be used in Java source code.toJavaCompliantTypeReference in class LightweightTypeReferencepublic JvmType getType()
getType in class LightweightTypeReferencepublic boolean isRawType()
LightweightTypeReferencetrue is this type points to a raw type.
That is, it points to a parameterized type but does not define type arguments or
it points to an external type parameter that has a raw type constraint.
Type parameters that are declared by the current owner are not considered to be raw types.
A type is also a raw type if it inherits from a raw type.isRawType in class LightweightTypeReferencepublic boolean isOwnedBy(ITypeReferenceOwner owner)
isOwnedBy in class LightweightTypeReferencepublic LightweightTypeReference getWrapperTypeIfPrimitive()
getWrapperTypeIfPrimitive in class LightweightTypeReferencepublic LightweightTypeReference getPrimitiveIfWrapperType()
getPrimitiveIfWrapperType in class LightweightTypeReferencepublic boolean isPrimitive()
isPrimitive in class LightweightTypeReference@Nullable public Primitives.Primitive getPrimitiveKind()
getPrimitiveKind in class LightweightTypeReference@Nullable public Primitives.Primitive getPrimitiveKindIfWrapperType()
getPrimitiveKindIfWrapperType in class LightweightTypeReferencepublic boolean isPrimitiveVoid()
isPrimitiveVoid in class LightweightTypeReferencepublic boolean isInterfaceType()
isInterfaceType in class LightweightTypeReferencepublic boolean isWrapper()
isWrapper in class LightweightTypeReferenceprotected java.util.List<LightweightTypeReference> getSuperTypes(TypeParameterSubstitutor<?> substitutor)
getSuperTypes in class LightweightTypeReference@Nullable public LightweightTypeReference getSuperType(java.lang.Class<?> rawType)
LightweightTypeReferencenull if the raw type
is not a valid super type of this type.getSuperType in class LightweightTypeReferencerawType - the raw type that should be resolved.@Nullable public LightweightTypeReference getSuperType(JvmType rawType)
LightweightTypeReferencegetSuperType in class LightweightTypeReferencerawType - the raw type that should be resolved.@Nullable public LightweightTypeReference getRawSuperType(JvmType rawType)
public java.util.List<LightweightTypeReference> getTypeArguments()
LightweightTypeReferenceList<String> is String.
? extends List<String>.
Raw types don't carry type arguments. Wildcards with more than one upper bound
don't carry type arguments.getTypeArguments in class LightweightTypeReferenceprotected ParameterizedTypeReference doCopyInto(ITypeReferenceOwner owner)
doCopyInto in class LightweightTypeReferenceprotected void copyTypeArguments(ParameterizedTypeReference result, ITypeReferenceOwner owner)
public boolean isResolved()
isResolved in class LightweightTypeReferencepublic void addTypeArgument(LightweightTypeReference argument)
public java.lang.String getSimpleName()
getSimpleName in class LightweightTypeReferencepublic java.lang.String getIdentifier()
getIdentifier in class LightweightTypeReferencepublic java.lang.String getUniqueIdentifier()
LightweightTypeReferencegetUniqueIdentifier in class LightweightTypeReferencepublic java.lang.String getJavaIdentifier()
getJavaIdentifier in class LightweightTypeReferenceprotected java.lang.String getAsString(java.lang.String type,
com.google.common.base.Function<LightweightTypeReference,java.lang.String> format)
public boolean isType(java.lang.Class<?> clazz)
LightweightTypeReferenceclazz.
Returns false if this is not exactly the given type, but a sub type, a
super type or a completely unrelated type.isType in class LightweightTypeReferencepublic void accept(TypeReferenceVisitor visitor)
accept in class LightweightTypeReferencepublic <Param> void accept(TypeReferenceVisitorWithParameter<Param> visitor, Param param)
accept in class LightweightTypeReference@Nullable public <Result> Result accept(TypeReferenceVisitorWithResult<Result> visitor)
accept in class LightweightTypeReference@Nullable public <Param,Result> Result accept(TypeReferenceVisitorWithParameterAndResult<Param,Result> visitor, Param param)
accept in class LightweightTypeReferencepublic FunctionTypeKind getFunctionTypeKind()
getFunctionTypeKind in class LightweightTypeReference@Nullable public FunctionTypeReference getAsFunctionTypeReference()
FunctionTypeReference if this reference
points to a function or procedure
or if it is already a function type reference.
Otherwise returns null.getAsFunctionTypeReference in class LightweightTypeReferenceFunctionTypes.getAsFunctionTypeReference(ParameterizedTypeReference)@Nullable public FunctionTypeReference tryConvertToFunctionTypeReference(boolean rawType)
FunctionTypeReference if the referenced type is a SAM type.
Returns null if this reference does not point to a valid function type.tryConvertToFunctionTypeReference in class LightweightTypeReferencerawType - if a raw view on the function type is sufficient.FunctionTypes.tryConvertToFunctionTypeReference(ParameterizedTypeReference, boolean)@Nullable public ArrayTypeReference tryConvertToArray()
Iterable
or already an array itself.
If the iterable's type is a primitive wrapper, the array is not the primitive array but
the wrapper array. May return null if the conversion is not possible.tryConvertToArray in class LightweightTypeReferenceArrayTypeReference or null.ArrayTypes.tryConvertToArray(ParameterizedTypeReference)@Nullable public LightweightTypeReference tryConvertToListType()
LightweightTypeReferenceList.
If the array's type is a primitive, the list's element type is the wrapper.
May return null if the conversion is not possible.tryConvertToListType in class LightweightTypeReferencenull.public ParameterizedTypeReference toInstanceTypeReference()
ArrayList<? extends Iterable<? extends String>>
is ArrayList<Iterable<? extends String>> since it is possible to create instances
of ArrayList<Iterable<? extends String>>.