public class TypeSubstitution
extends java.lang.Object
Constructor and Description |
---|
TypeSubstitution()
Create a new TypeSubstitution with no initial substitution rules.
|
TypeSubstitution(java.util.function.Function<? super java.lang.reflect.Type,? extends java.lang.reflect.Type> mapping)
Create a new TypeSubstitution to apply the given mapping function.
|
TypeSubstitution(java.util.Map<? extends java.lang.reflect.Type,? extends java.lang.reflect.Type> mapping)
Create a new TypeSubstitution to apply the given mapping.
|
Modifier and Type | Method and Description |
---|---|
java.lang.reflect.Type |
resolve(java.lang.reflect.Type type)
Resolve the result of this substitution as applied to the given type.
|
protected java.lang.reflect.Type |
resolve(java.lang.reflect.Type type,
IdentityProperty<java.lang.Boolean> changed) |
TypeSubstitution |
where(java.util.function.Predicate<? super java.lang.reflect.Type> from,
java.util.function.Function<? super java.lang.reflect.Type,? extends java.lang.reflect.Type> to)
Create a new TypeSubstitution by adding a specific single substitution rule
to the receiver of the invocation.
|
TypeSubstitution |
where(java.lang.reflect.Type from,
java.lang.reflect.Type to)
Create a new TypeSubstitution by adding a specific single substitution rule
to the receiver of the invocation.
|
TypeSubstitution |
withIsomorphism(Isomorphism isomorphism)
Create a new TypeSubstitution which is the same as the receiver with the
additional behavior that it maps types according to the given
Isomorphism . |
TypeSubstitution |
withTypeVariables()
Create a new TypeSubstitution which is the same as the receiver with the
additional behavior that type variables are also included for bounds
substitution.
|
public TypeSubstitution()
public TypeSubstitution(java.util.function.Function<? super java.lang.reflect.Type,? extends java.lang.reflect.Type> mapping)
Map
of Type instances
to other Type instances, then pass the method reference of
Map.get(Object)
for that map to this constructor. For this specific
example use case though, TypeSubstitution(Map)
would perform
slightly better.mapping
- A mapping function for transforming encountered types to their
substitution types.public TypeSubstitution(java.util.Map<? extends java.lang.reflect.Type,? extends java.lang.reflect.Type> mapping)
TypeSubstitution(Function)
constructor, as it can skip type traversal for empty maps.mapping
- A mapping function for transforming encountered types to their
substitution types.public TypeSubstitution where(java.lang.reflect.Type from, java.lang.reflect.Type to)
from
- The type to match in application of this rule.to
- The type to substitute for types which match the rule.public TypeSubstitution where(java.util.function.Predicate<? super java.lang.reflect.Type> from, java.util.function.Function<? super java.lang.reflect.Type,? extends java.lang.reflect.Type> to)
from
- The type matching condition of the new rule.to
- The substitution transformation to apply to types matching the given
condition.public TypeSubstitution withTypeVariables()
public TypeSubstitution withIsomorphism(Isomorphism isomorphism)
Isomorphism
.isomorphism
- an isomorphismpublic java.lang.reflect.Type resolve(java.lang.reflect.Type type)
type
- The type for which we want to make a substitution.protected java.lang.reflect.Type resolve(java.lang.reflect.Type type, IdentityProperty<java.lang.Boolean> changed)