@NonNullByDefault
public abstract class LightweightTypeReference
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
LightweightTypeReference.IdentifierFunction |
static class |
LightweightTypeReference.JavaIdentifierFunction |
static class |
LightweightTypeReference.SimpleNameFunction |
static class |
LightweightTypeReference.UniqueIdentifierFunction |
Modifier and Type | Field and Description |
---|---|
static int |
KIND_ANY_TYPE_REFERENCE |
static int |
KIND_ARRAY_TYPE_REFERENCE |
static int |
KIND_COMPOUND_TYPE_REFERENCE |
static int |
KIND_FUNCTION_TYPE_REFERENCE |
static int |
KIND_LIGHTWEIGHT_TYPE_REFERENCE |
static int |
KIND_PARAMETERIZED_TYPE_REFERENCE |
static int |
KIND_UNBOUND_TYPE_REFERENCE |
static int |
KIND_UNKNOWN_TYPE_REFERENCE |
static int |
KIND_WILDCARD_TYPE_REFERENCE |
Modifier | Constructor and Description |
---|---|
protected |
LightweightTypeReference(ITypeReferenceOwner owner) |
Modifier and Type | Method and Description |
---|---|
void |
accept(TypeReferenceVisitor visitor) |
<Result> Result |
accept(TypeReferenceVisitorWithNonNullResult<Result> visitor) |
<Param> void |
accept(TypeReferenceVisitorWithParameter<Param> visitor,
Param param) |
<Param,Result> |
accept(TypeReferenceVisitorWithParameterAndNonNullResult<Param,Result> visitor,
Param param) |
<Param,Result> |
accept(TypeReferenceVisitorWithParameterAndResult<Param,Result> visitor,
Param param) |
<Result> Result |
accept(TypeReferenceVisitorWithResult<Result> visitor) |
protected void |
collectSuperTypes(int level,
java.util.List<LightweightTypeReference> references,
TypeParameterSubstitutor<?> substitutor,
SuperTypeAcceptor acceptor,
java.util.Set<JvmType> seenTypes) |
void |
collectSuperTypes(SuperTypeAcceptor acceptor) |
LightweightTypeReference |
copyInto(ITypeReferenceOwner owner) |
protected TypeParameterSubstitutor<?> |
createSubstitutor() |
protected abstract LightweightTypeReference |
doCopyInto(ITypeReferenceOwner owner) |
protected <T> java.util.List<T> |
expose(java.util.List<T> list) |
protected JvmType |
findNonNullType(java.lang.Class<?> type) |
protected JvmType |
findType(java.lang.Class<?> type) |
java.util.List<LightweightTypeReference> |
getAllSuperTypes()
Returns the list of all super types which includes the super class and the
implemented interfaces.
|
FunctionTypeReference |
getAsFunctionTypeReference()
Returns the equivalent
FunctionTypeReference if this reference
points to a function or procedure
or if it is already a function type reference. |
LightweightTypeReference |
getComponentType()
Returns the component type of the current array type.
|
FunctionTypeKind |
getFunctionTypeKind() |
abstract java.lang.String |
getIdentifier() |
LightweightTypeReference |
getInvariantBoundSubstitute() |
abstract java.lang.String |
getJavaIdentifier() |
int |
getKind()
Subclasses must override this method.
|
LightweightTypeReference |
getLowerBoundSubstitute() |
java.util.List<LightweightTypeReference> |
getMultiTypeComponents() |
protected java.util.List<LightweightTypeReference> |
getNonInterfaceTypes(java.util.List<LightweightTypeReference> components) |
ITypeReferenceOwner |
getOwner() |
LightweightTypeReference |
getPrimitiveIfWrapperType() |
Primitives.Primitive |
getPrimitiveKind() |
Primitives.Primitive |
getPrimitiveKindIfWrapperType() |
LightweightTypeReference |
getRawTypeReference() |
java.util.List<JvmType> |
getRawTypes() |
protected CommonTypeComputationServices |
getServices() |
abstract 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.
|
java.util.List<LightweightTypeReference> |
getSuperTypes()
Returns the list of immediate super types which includes the super class and the
implemented interfaces.
|
protected abstract java.util.List<LightweightTypeReference> |
getSuperTypes(TypeParameterSubstitutor<?> substitutor) |
abstract JvmType |
getType() |
java.util.List<LightweightTypeReference> |
getTypeArguments()
Returns the type arguments of this reference if it has any.
|
protected TypesFactory |
getTypesFactory() |
abstract java.lang.String |
getUniqueIdentifier()
Returns an identifier that allows to disambiguate type parameter names that have
different origins.
|
protected java.lang.String |
getUniqueIdentifier(JvmType type) |
LightweightTypeReference |
getUpperBoundSubstitute() |
LightweightTypeReference |
getWrapperTypeIfPrimitive() |
protected LightweightTypeReference |
internalFindTopLevelType(java.lang.Class<?> rawType) |
TypeConformanceResult |
internalIsAssignableFrom(LightweightTypeReference reference,
TypeConformanceComputationArgument argument) |
boolean |
isAny() |
boolean |
isArray() |
boolean |
isAssignableFrom(java.lang.Class<?> clazz)
Determines if this type reference denotes the same type or a supertype of
the given
clazz . |
boolean |
isAssignableFrom(JvmType type)
Determines if this type reference denotes the same type or a supertype of
the given
type . |
boolean |
isAssignableFrom(LightweightTypeReference reference)
Determines if this type reference denotes the same or a supertype of
the given
reference . |
boolean |
isAssignableFrom(LightweightTypeReference reference,
TypeConformanceComputationArgument argument) |
boolean |
isFunctionType() |
boolean |
isInterfaceType() |
boolean |
isMultiType() |
boolean |
isOwnedBy(ITypeReferenceOwner owner) |
boolean |
isPrimitive() |
boolean |
isPrimitiveVoid() |
boolean |
isRawType()
Returns
true is this type points to a raw type. |
boolean |
isResolved() |
boolean |
isSubtypeOf(java.lang.Class<?> clazz)
Determines if this type reference denotes the same type or a subtype of
the given
clazz . |
boolean |
isSubtypeOf(JvmType type)
Determines if this type reference denotes the same type or a subtype of
the given
type . |
boolean |
isSynonym() |
abstract boolean |
isType(java.lang.Class<?> clazz)
Returns true if this type reference represents an type with the given
raw type
clazz . |
boolean |
isUnknown() |
boolean |
isValidHint()
|
abstract boolean |
isVisible(IVisibilityHelper visibilityHelper)
Returns
true if this type is fully visible according to the given visibilityHelper . |
boolean |
isWildcard() |
boolean |
isWrapper() |
JvmTypeReference |
toJavaCompliantTypeReference()
Converts this type reference to a
JvmTypeReference that can
be used in Java source code. |
abstract JvmTypeReference |
toJavaCompliantTypeReference(IVisibilityHelper visibilityHelper)
Converts this type reference to a
JvmTypeReference that can
be used in Java source code. |
protected JvmTypeReference |
toJavaCompliantTypeReference(java.util.List<LightweightTypeReference> types,
IVisibilityHelper visibilityHelper) |
LightweightTypeReference |
toJavaType()
Converts types to references that can be expressed as Java type references
in source code.
|
CompoundTypeReference |
toMultiType(LightweightTypeReference reference) |
java.lang.String |
toString() |
abstract 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 . |
public static final int KIND_LIGHTWEIGHT_TYPE_REFERENCE
public static final int KIND_ANY_TYPE_REFERENCE
public static final int KIND_ARRAY_TYPE_REFERENCE
public static final int KIND_COMPOUND_TYPE_REFERENCE
public static final int KIND_PARAMETERIZED_TYPE_REFERENCE
public static final int KIND_UNBOUND_TYPE_REFERENCE
public static final int KIND_UNKNOWN_TYPE_REFERENCE
public static final int KIND_WILDCARD_TYPE_REFERENCE
public static final int KIND_FUNCTION_TYPE_REFERENCE
protected LightweightTypeReference(ITypeReferenceOwner owner)
public int getKind()
public java.util.List<LightweightTypeReference> getTypeArguments()
List<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.public boolean isResolved()
public ITypeReferenceOwner getOwner()
protected TypesFactory getTypesFactory()
protected CommonTypeComputationServices getServices()
public boolean isOwnedBy(ITypeReferenceOwner owner)
protected <T> java.util.List<T> expose(@Nullable java.util.List<T> list)
public abstract JvmTypeReference toTypeReference()
public final JvmTypeReference toJavaCompliantTypeReference()
JvmTypeReference
that can
be used in Java source code.public abstract boolean isVisible(IVisibilityHelper visibilityHelper)
true
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.public abstract JvmTypeReference toJavaCompliantTypeReference(IVisibilityHelper visibilityHelper)
JvmTypeReference
that can
be used in Java source code.protected JvmTypeReference toJavaCompliantTypeReference(java.util.List<LightweightTypeReference> types, IVisibilityHelper visibilityHelper)
@Nullable protected java.util.List<LightweightTypeReference> getNonInterfaceTypes(java.util.List<LightweightTypeReference> components)
@Nullable public abstract JvmType getType()
public LightweightTypeReference getWrapperTypeIfPrimitive()
public LightweightTypeReference getPrimitiveIfWrapperType()
@Nullable public Primitives.Primitive getPrimitiveKind()
@Nullable public Primitives.Primitive getPrimitiveKindIfWrapperType()
public java.util.List<JvmType> getRawTypes()
public LightweightTypeReference getRawTypeReference()
public LightweightTypeReference getUpperBoundSubstitute()
public LightweightTypeReference getLowerBoundSubstitute()
public LightweightTypeReference getInvariantBoundSubstitute()
public boolean isRawType()
true
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.public boolean isArray()
public boolean isAny()
public boolean isUnknown()
public boolean isValidHint()
@Nullable public LightweightTypeReference tryConvertToListType()
List
.
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.null
.@Nullable public LightweightTypeReference getComponentType()
null
.isArray()
public java.util.List<LightweightTypeReference> getSuperTypes()
List<String>
is Collection<String>
rather than Collection<E>
.@Nullable public LightweightTypeReference getSuperType(java.lang.Class<?> rawType)
null
if the raw type
is not a valid super type of this type.rawType
- the raw type that should be resolved.@Nullable public LightweightTypeReference getSuperType(JvmType rawType)
rawType
- the raw type that should be resolved.public java.util.List<LightweightTypeReference> getAllSuperTypes()
ArrayList<String>
includes
List<String>
and Collection<String>
rather than Collection<E>
.protected TypeParameterSubstitutor<?> createSubstitutor()
protected abstract java.util.List<LightweightTypeReference> getSuperTypes(TypeParameterSubstitutor<?> substitutor)
public void collectSuperTypes(SuperTypeAcceptor acceptor)
protected void collectSuperTypes(int level, java.util.List<LightweightTypeReference> references, TypeParameterSubstitutor<?> substitutor, SuperTypeAcceptor acceptor, java.util.Set<JvmType> seenTypes)
public boolean isPrimitive()
public boolean isWrapper()
public boolean isPrimitiveVoid()
public boolean isAssignableFrom(LightweightTypeReference reference)
reference
.public boolean isAssignableFrom(LightweightTypeReference reference, TypeConformanceComputationArgument argument)
public TypeConformanceResult internalIsAssignableFrom(LightweightTypeReference reference, TypeConformanceComputationArgument argument)
public boolean isAssignableFrom(java.lang.Class<?> clazz)
clazz
.public boolean isAssignableFrom(JvmType type)
type
.public boolean isSubtypeOf(java.lang.Class<?> clazz)
clazz
.public boolean isSubtypeOf(JvmType type)
type
.public LightweightTypeReference copyInto(ITypeReferenceOwner owner)
protected abstract LightweightTypeReference doCopyInto(ITypeReferenceOwner owner)
public final java.lang.String toString()
toString
in class java.lang.Object
public abstract java.lang.String getSimpleName()
public abstract java.lang.String getIdentifier()
public abstract java.lang.String getUniqueIdentifier()
protected java.lang.String getUniqueIdentifier(JvmType type)
public abstract java.lang.String getJavaIdentifier()
@Nullable protected JvmType findType(java.lang.Class<?> type)
@Nullable protected LightweightTypeReference internalFindTopLevelType(java.lang.Class<?> rawType)
protected JvmType findNonNullType(java.lang.Class<?> type)
public abstract boolean isType(java.lang.Class<?> clazz)
clazz
.
Returns false if this is not exactly the given type, but a sub type, a
super type or a completely unrelated type.public void accept(TypeReferenceVisitor visitor)
public <Param> void accept(TypeReferenceVisitorWithParameter<Param> visitor, Param param)
@Nullable public <Result> Result accept(TypeReferenceVisitorWithResult<Result> visitor)
@Nullable public <Param,Result> Result accept(TypeReferenceVisitorWithParameterAndResult<Param,Result> visitor, Param param)
public <Result> Result accept(TypeReferenceVisitorWithNonNullResult<Result> visitor)
public <Param,Result> Result accept(TypeReferenceVisitorWithParameterAndNonNullResult<Param,Result> visitor, Param param)
public CompoundTypeReference toMultiType(LightweightTypeReference reference)
public boolean isFunctionType()
public boolean isInterfaceType()
public FunctionTypeKind getFunctionTypeKind()
@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
.@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.rawType
- if a raw view on the function type is sufficient.getAsFunctionTypeReference()
@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.ArrayTypeReference
or null
.public boolean isWildcard()
public boolean isMultiType()
public boolean isSynonym()
public LightweightTypeReference toJavaType()
public java.util.List<LightweightTypeReference> getMultiTypeComponents()