public class TypeResolver extends java.lang.Object implements DeepCopyable<TypeResolver>
A TypeResolver represents a view over an underlying BoundSet,
and provides a number of important functionalities for interacting with that
BoundSet. Multiple TypeResolvers can provide different views
of the same BoundSet instance.
Whenever any InferenceVariable is created by way of a
TypeResolver instance, that InferenceVariable will be
associated with a particular GenericDeclaration. Within this context,
which is so described by a GenericDeclaration, at most only one
InferenceVariable may by created for any given TypeVariable.
A TypeResolver always creates InferenceVariable according to
the behavior of inferTypeParameters(GenericDeclaration).
| Constructor and Description |
|---|
TypeResolver()
Create a new resolver over a new bound set.
|
TypeResolver(BoundSet bounds)
Create a new
TypeResolver over the given BoundSet. |
| Modifier and Type | Method and Description |
|---|---|
TypeResolver |
copy() |
TypeResolver |
deepCopy(Isomorphism isomorphism)
Create a copy of an existing resolver.
|
BoundSet |
getBounds() |
java.lang.reflect.Type |
getInstantiation(InferenceVariable variable)
Resolve the proper instantiation of a given
InferenceVariable if one
exists. |
TypeResolver |
incorporateBounds(BoundSet bounds)
Incorporate the given bounds into the bounds of the resolver.
|
java.lang.reflect.GenericArrayType |
inferTypeArguments(java.lang.reflect.GenericArrayType type)
Add inference variables for the type parameters of the given type to the
resolver, then incorporate containment constraints based on the arguments of
the given type.
|
java.lang.reflect.ParameterizedType |
inferTypeArguments(java.lang.reflect.ParameterizedType type)
Add inference variables for the type parameters of the given type to the
resolver, then incorporate containment constraints based on the arguments of
the given type.
|
java.lang.reflect.ParameterizedType |
inferTypeParameters(java.lang.Class<?> declaration) |
java.util.stream.Stream<java.util.Map.Entry<java.lang.reflect.TypeVariable<?>,InferenceVariable>> |
inferTypeParameters(java.lang.reflect.GenericDeclaration declaration)
Each type variable within the given
GenericDeclaration, and each
non-statically enclosing declaration thereof, is incorporated into the
backing BoundSet. |
java.util.stream.Stream<java.util.Map.Entry<java.lang.reflect.TypeVariable<?>,InferenceVariable>> |
inferTypeParameters(java.lang.reflect.GenericDeclaration declaration,
java.util.Map<java.lang.reflect.TypeVariable<?>,? extends java.lang.reflect.Type> existingCaptures) |
java.util.stream.Stream<java.util.Map.Entry<java.lang.reflect.TypeVariable<?>,InferenceVariable>> |
inferTypeParameters(java.lang.reflect.GenericDeclaration declaration,
java.lang.reflect.ParameterizedType enclosing)
Each type variable within the given
GenericDeclaration, and each
non-statically enclosing declaration thereof, is incorporated into the
backing BoundSet. |
InferenceVariable |
inferWildcardType(java.lang.reflect.WildcardType type)
Incorporate a new inference variable for a given wildcard type, and add the
bounds of the wildcard as bounds to the inference variable.
|
TypeResolver |
reduceConstraint(ConstraintFormula constraintFormula)
Reduce the given constraint formula into the bound set of the resolver.
|
java.util.stream.Stream<java.util.Map.Entry<InferenceVariable,java.lang.reflect.Type>> |
resolve()
Infer proper instantiations for each inference variable registered within
this
TypeResolver instance. |
java.util.stream.Stream<java.util.Map.Entry<InferenceVariable,java.lang.reflect.Type>> |
resolve(java.util.Collection<? extends InferenceVariable> variables)
Infer proper instantiations for the given
InferenceVariables. |
java.util.stream.Stream<java.util.Map.Entry<InferenceVariable,java.lang.reflect.Type>> |
resolve(InferenceVariable... variables)
Infer proper instantiations for the given
InferenceVariables. |
java.lang.reflect.Type |
resolve(InferenceVariable inferenceVariable)
Infer a proper instantiations for a single given
InferenceVariable. |
java.lang.reflect.Type |
resolve(java.lang.reflect.Type type)
Infer a proper instantiations for each
InferenceVariable mentioned by
the given type. |
java.lang.reflect.Type |
substituteInstantiations(java.lang.reflect.Type type)
Derive a new type from the type given, with any mentioned instances of
InferenceVariable substituted with their proper instantiations where
available, as per getInstantiation(InferenceVariable). |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitdeepCopypublic TypeResolver(BoundSet bounds)
TypeResolver over the given BoundSet.bounds - The exact bound set we wish to create a resolver over. Operations on
the new resolver may mutate the given bound set.public TypeResolver()
public TypeResolver copy()
copy in interface Copyable<TypeResolver>public TypeResolver deepCopy(Isomorphism isomorphism)
deepCopy in interface Copyable<TypeResolver>deepCopy in interface DeepCopyable<TypeResolver>isomorphism - an isomorphism for inference variablespublic BoundSet getBounds()
public java.util.stream.Stream<java.util.Map.Entry<java.lang.reflect.TypeVariable<?>,InferenceVariable>> inferTypeParameters(java.lang.reflect.GenericDeclaration declaration, java.util.Map<java.lang.reflect.TypeVariable<?>,? extends java.lang.reflect.Type> existingCaptures)
public java.util.stream.Stream<java.util.Map.Entry<java.lang.reflect.TypeVariable<?>,InferenceVariable>> inferTypeParameters(java.lang.reflect.GenericDeclaration declaration, java.lang.reflect.ParameterizedType enclosing)
GenericDeclaration, and each
non-statically enclosing declaration thereof, is incorporated into the
backing BoundSet.declaration - the declaration we wish to incorporateenclosing - the parameterized enclosing declarationInferenceVariables on the given declaration,
to their new capturing InferenceVariablespublic java.util.stream.Stream<java.util.Map.Entry<java.lang.reflect.TypeVariable<?>,InferenceVariable>> inferTypeParameters(java.lang.reflect.GenericDeclaration declaration)
GenericDeclaration, and each
non-statically enclosing declaration thereof, is incorporated into the
backing BoundSet.declaration - the declaration we wish to incorporateInferenceVariables on the given
declaration, to their new capturing InferenceVariablespublic java.lang.reflect.GenericArrayType inferTypeArguments(java.lang.reflect.GenericArrayType type)
type - The type whose generic type arguments we wish to perform inference
operations over.public java.lang.reflect.ParameterizedType inferTypeArguments(java.lang.reflect.ParameterizedType type)
type - The type whose generic type arguments we wish to perform inference
operations over.public java.lang.reflect.ParameterizedType inferTypeParameters(java.lang.Class<?> declaration)
public InferenceVariable inferWildcardType(java.lang.reflect.WildcardType type)
type - The wildcard type to capture as a bounded inference variable.public java.util.stream.Stream<java.util.Map.Entry<InferenceVariable,java.lang.reflect.Type>> resolve()
TypeResolver instance.public java.lang.reflect.Type resolve(java.lang.reflect.Type type)
InferenceVariable mentioned by
the given type.type - the type whose proper form we wish to inferInferenceVariable mentionedpublic java.lang.reflect.Type resolve(InferenceVariable inferenceVariable)
InferenceVariable.inferenceVariable - the type whose proper form we wish to inferInferenceVariablepublic java.util.stream.Stream<java.util.Map.Entry<InferenceVariable,java.lang.reflect.Type>> resolve(InferenceVariable... variables)
InferenceVariables.variables - the inference variables for which we wish to infer instantiationspublic java.util.stream.Stream<java.util.Map.Entry<InferenceVariable,java.lang.reflect.Type>> resolve(java.util.Collection<? extends InferenceVariable> variables)
InferenceVariables.variables - The inference variables for which we wish to infer instantiations.public java.lang.reflect.Type substituteInstantiations(java.lang.reflect.Type type)
InferenceVariable substituted with their proper instantiations where
available, as per getInstantiation(InferenceVariable).type - The type we wish to resolve.public java.lang.reflect.Type getInstantiation(InferenceVariable variable)
InferenceVariable if one
exists.variable - The inference variable whose proper instantiation we wish to
determine.InferenceVariable if
one exists, otherwise the InferenceVariable itself.public TypeResolver incorporateBounds(BoundSet bounds)
bounds - the bounds to incorporatepublic TypeResolver reduceConstraint(ConstraintFormula constraintFormula)
constraintFormula - the constraint formula to reduce