S
- the type of declarationpublic interface DeclarationToken<S extends DeclarationToken<S>>
Modifier and Type | Method and Description |
---|---|
default java.util.stream.Stream<TypeArgument<?>> |
getAllTypeArguments() |
default int |
getAllTypeParameterCount() |
default java.util.stream.Stream<TypeParameter<?>> |
getAllTypeParameters() |
java.util.Optional<? extends DeclarationToken<?>> |
getOwningDeclaration() |
java.util.stream.Stream<TypeArgument<?>> |
getTypeArguments() |
int |
getTypeParameterCount() |
java.util.stream.Stream<TypeParameter<?>> |
getTypeParameters() |
boolean |
isGeneric() |
boolean |
isRaw() |
default <U> TypeArgument<U> |
resolveTypeArgument(TypeParameter<U> parameter)
Resolve the instantiation of the given type variable in the context of this
declaration.
|
default java.lang.reflect.Type |
resolveTypeArgument(java.lang.reflect.TypeVariable<?> parameter) |
DeclarationToken<?> |
withAllTypeArguments(java.util.List<java.lang.reflect.Type> typeArguments)
Derive a new
DeclarationToken instance with the given type argument
parameterization. |
DeclarationToken<?> |
withAllTypeArguments(java.lang.reflect.Type... typeArguments) |
S |
withTypeArguments(java.util.Collection<? extends TypeArgument<?>> arguments)
Derive a new
ExecutableToken instance from this, with types
substituted according to the given arguments. |
DeclarationToken<?> |
withTypeArguments(java.util.List<java.lang.reflect.Type> typeArguments)
As @see
withAllTypeArguments(List) , but only providing arguments for
the parameters occurring directly on the declaration. |
DeclarationToken<?> |
withTypeArguments(java.lang.reflect.Type... typeArguments) |
default S |
withTypeArguments(TypeArgument<?>... arguments)
Derive a new
ExecutableToken instance from this, with the given
instantiation substituted for the given TypeVariable . |
boolean isRaw()
boolean isGeneric()
java.util.Optional<? extends DeclarationToken<?>> getOwningDeclaration()
default int getAllTypeParameterCount()
default java.util.stream.Stream<TypeParameter<?>> getAllTypeParameters()
default java.util.stream.Stream<TypeArgument<?>> getAllTypeArguments()
int getTypeParameterCount()
java.util.stream.Stream<TypeParameter<?>> getTypeParameters()
Executable
, or their inference variables if not yet
instantiated.java.util.stream.Stream<TypeArgument<?>> getTypeArguments()
Executable
, or their inference variables if not yet
instantiated.default S withTypeArguments(TypeArgument<?>... arguments)
ExecutableToken
instance from this, with the given
instantiation substituted for the given TypeVariable
.
The substitution will only succeed if it is compatible with the bounds on
that type variable, and if it is more specific than the current type of the
type variable, whether it is an InferenceVariable
, a
TypeVariableCapture
, or another class of Type
.
For example, the following method could be used to derive instances of
TypeToken over different parameterizations of List<?>
at runtime.
public TypeToken<List<T>> getListType(TypeToken<T> elementType)} {
return new TypeToken<T>()} {}.withTypeArguments(new TypeParameter<T>() {}.as(elementType));
}
This behavior is different from withTypeArguments(List)
, which
re-instantiates every parameter on the declaration rather than performing a
substitution for arbitrary type variables.
arguments
- the type variable instantiationsExecutableToken
instance with the given
instantiation substituted for the given type variableS withTypeArguments(java.util.Collection<? extends TypeArgument<?>> arguments)
ExecutableToken
instance from this, with types
substituted according to the given arguments.
More specifically, each of the given arguments represents a type variable and an instantiation for that type variable. Occurrences of those type variables in the declaration will be substituted for their instantiations in the derived declaration.
The substitution will only succeed if it results in a valid parameterization of the declaration.
For example, the following method could be used to derive instances of
TypeToken over different parameterizations of List<?>
at runtime.
public TypeToken<List<T>> getListType(TypeToken<T> elementType)} {
return new TypeToken<T>()} {}.withTypeArguments(new TypeParameter<T>() {}.as(elementType));
}
arguments
- the type variable instantiationsExecutableToken
instance with the given
instantiation substituted for the given type variabledefault <U> TypeArgument<U> resolveTypeArgument(TypeParameter<U> parameter)
U
- the type of the type variable to resolveparameter
- the type parameterdefault java.lang.reflect.Type resolveTypeArgument(java.lang.reflect.TypeVariable<?> parameter)
resolveTypeArgument(TypeParameter)
DeclarationToken<?> withAllTypeArguments(java.lang.reflect.Type... typeArguments)
withTypeArguments(List)
DeclarationToken<?> withTypeArguments(java.lang.reflect.Type... typeArguments)
withTypeArguments(List)
DeclarationToken<?> withAllTypeArguments(java.util.List<java.lang.reflect.Type> typeArguments)
DeclarationToken
instance with the given type argument
parameterization.
The types in the given list correspond, in order, to the
type parameters
of this declaration. The current
parameterization of the declaration is substituted for that given.
Each substitution will only succeed if it is compatible with the bounds on
that type variable, and if it is more specific than the current argument,
whether it is an InferenceVariable
, a TypeVariableCapture
, or
another kind of Type
.
This behavior is different from withTypeArguments(Collection)
, which
performs a substitution for arbitrary type variables rather than
re-instantiating every parameter on the declaration.
typeArguments
- a list of arguments for each generic type parameter of the
underlying declarationDeclarationToken
instance with the given
instantiations substituted for each generic type parameter, in orderDeclarationToken<?> withTypeArguments(java.util.List<java.lang.reflect.Type> typeArguments)
withAllTypeArguments(List)
, but only providing arguments for
the parameters occurring directly on the declaration.