R
- the type of value returned from visiting a typeP
- an optional context parameter that is supplied to the visitor when visiting a typepublic interface TypeVisitor<R,P>
if-else
boiler-plate with instanceof
checks and casts. To visit a type, use
the main entry-point method: visit(Type, Object)
.Modifier and Type | Interface and Description |
---|---|
static class |
TypeVisitor.Builder<R,P>
A builder of visitors, using functional interfaces as the building blocks.
|
Modifier and Type | Method and Description |
---|---|
default R |
defaultAction(Type type,
P param)
The default action for visiting a type, called when visiting a type where the corresponding
visit* method has not been overridden. |
default R |
visit(Type type,
P param)
Visits the given type.
|
default R |
visitClass(Class<?> clazz,
P param)
Invoked when the visited type is a class token.
|
default R |
visitGenericArrayType(GenericArrayType arrayType,
P param)
Invoked when the visited type is a generic array type.
|
default R |
visitParameterizedType(ParameterizedType parameterizedType,
P param)
Invoked when the visited type is a parameterized type.
|
default R |
visitTypeVariable(TypeVariable<?> typeVariable,
P param)
Invoked when the visited type is a type variable.
|
default R |
visitUnknownType(Type type,
P param)
Invoked when the visited type is not a known sub-type of the
Type interface. |
default R |
visitWildcardType(WildcardType wildcardType,
P param)
Invoked when the visited type is a wildcard type.
|
default R visit(Type type, P param)
type
- the typeparam
- the context parameterdefault R defaultAction(Type type, P param)
visit*
method has not been overridden.
The default implementation returns null
.
type
- a generic typeparam
- the context parameterdefault R visitClass(Class<?> clazz, P param)
clazz
- the class tokenparam
- the context parameterdefault R visitParameterizedType(ParameterizedType parameterizedType, P param)
parameterizedType
- the parameterized typeparam
- the context parameterdefault R visitGenericArrayType(GenericArrayType arrayType, P param)
arrayType
- the generic array typeparam
- the context parameterdefault R visitWildcardType(WildcardType wildcardType, P param)
wildcardType
- the wildcard typeparam
- the context parameterdefault R visitTypeVariable(TypeVariable<?> typeVariable, P param)
typeVariable
- the type variableparam
- the context parameterdefault R visitUnknownType(Type type, P param)
Type
interface.
Other visit*
methods have a default implementation that calls
defaultAction(Type, Object)
. But the default implementation of this method is
different. Instead, it throws an UnknownTypeException
.
type
- the typeparam
- the context parameter