public class InferenceVariable
extends java.lang.Object
implements java.lang.reflect.Type
An inference variable can be thought of as a placeholder for an
instantiation of a TypeVariable
of which we do not yet know
the exact type. An InferenceVariable
alone has no bounds or type
information attached to it. Instead, typically, they are contained within the
context of one or more BoundSet
s, which will track bounds on a set of
inference variables such they their exact type can ultimately be inferred.
Constructor and Description |
---|
InferenceVariable()
Create a new inference variable with a basic generated name, which is
contained within this bound set.
|
InferenceVariable(java.lang.String name)
Create a new inference variable with the given name.
|
Modifier and Type | Method and Description |
---|---|
static java.lang.reflect.ParameterizedType |
captureConversion(java.lang.reflect.ParameterizedType type,
BoundSet bounds)
Create fresh
InferenceVariable s for each parameter of the given
type - and each non-statically enclosing type thereof - which is a
WildcardType . |
static java.util.stream.Stream<InferenceVariable> |
getMentionedBy(java.lang.reflect.Type type)
Find all inference variables mentioned by a type, whether in any bounds,
parameters, array types, etc.
|
java.lang.String |
getName() |
long |
getNumber() |
static boolean |
isProperType(java.lang.reflect.Type type)
Determine whether a given type is proper.
|
java.lang.String |
toString() |
public InferenceVariable()
public InferenceVariable(java.lang.String name)
name
- A name to assign to a new inference variable.public java.lang.String getName()
public long getNumber()
public java.lang.String toString()
toString
in class java.lang.Object
public static java.lang.reflect.ParameterizedType captureConversion(java.lang.reflect.ParameterizedType type, BoundSet bounds)
InferenceVariable
s for each parameter of the given
type - and each non-statically enclosing type thereof - which is a
WildcardType
. New bounds based on the bounds of those wildcards,
and the bounds of the TypeVariable
s they substitute, will be
incorporated into the given BoundSet
, along with a
CaptureConversion
bound representing this capture conversion. The
process of capture conversion is described in more detail in the Java 8
language specification.type
- A parameterised type whose wildcard type arguments, if present, we
wish to capture as inference variables.bounds
- The bound set we wish to create any fresh inference variables
within, and incorporate any newly implied bounds into.InferenceVariable
s substituted for the type
arguments.public static java.util.stream.Stream<InferenceVariable> getMentionedBy(java.lang.reflect.Type type)
type
- The type in which to find inference variable mentions.public static boolean isProperType(java.lang.reflect.Type type)
type
- The type for which to determine properness.