Package io.activej.types.scanner
Class TypeScannerRegistry.Context<R>
java.lang.Object
io.activej.types.scanner.TypeScannerRegistry.Context<R>
- Type Parameters:
R- a type of context data
- Enclosing class:
- TypeScannerRegistry<R>
A context that encapsulates a
TypeScannerRegistry.Mapping<R> and two stacks
(a context stack and an argument stack).
May hold an arbitrary context value-
Method Summary
Modifier and TypeMethodDescriptionReturns an annotated type ofthiscontext<A extends Annotation>
AgetAnnotation(Class<A> clazz) Returns an annotation of a given annotation type fromthiscontext annotations ornullif none matchesReturns an array of annotations ofthiscontext annotated typeReturns an argument stack ofthiscontextReturns a context value if it is present, ornullotherwiseClass<?>Returns a raw type ofthiscontextgetStack()Returns a context stack ofthiscontextgetType()Returns a type ofthiscontextgetTypeArgument(int n) Returns nth annotated type argument ofthiscontextReturns an array of annotated type arguments forthiscontextintReturns a number of annotated type arguments forthiscontextbooleanhasAnnotation(Class<? extends Annotation> clazz) Checks whetherthiscontext annotations contain an annotation of a given classbooleanChecks whetherthiscontext has any type argumentspush(AnnotatedType annotatedType) Pushesthiscontext onto a context stack and returns a new contextscan(AnnotatedType annotatedType) Scans a given annotated type and returns a resultingTypeScannerRegistry.ContextobjectScans a given type and returns a resultingTypeScannerRegistry.Contextobject<X extends R>
XscanTypeArgument(int n) Scans nth type argument and returns a resultingTypeScannerRegistry.ContextobjecttoString()withContextValue(Object value) Sets a context value to this contextwithMapping(TypeScannerRegistry.Mapping<R> mappingFn) Sets a mapping that defines howTypeScannerRegistry.Contextvalue should be retrieved from thisTypeScannerRegistry.Context<R>withMapping(BiFunction<TypeScannerRegistry.Mapping<R>, TypeScannerRegistry.Context<R>, R> mappingFn) Adds a mapping that defines howTypeScannerRegistry.Contextvalue should be retrieved from aTypeScannerRegistry.Context<R>and a previous mapping
-
Method Details
-
withContextValue
Sets a context value to this context- Parameters:
value- a context value
-
withMapping
Sets a mapping that defines howTypeScannerRegistry.Contextvalue should be retrieved from thisTypeScannerRegistry.Context<R>- Parameters:
mappingFn- a mapping function
-
withMapping
public TypeScannerRegistry.Context<R> withMapping(BiFunction<TypeScannerRegistry.Mapping<R>, TypeScannerRegistry.Context<R>, R> mappingFn) Adds a mapping that defines howTypeScannerRegistry.Contextvalue should be retrieved from aTypeScannerRegistry.Context<R>and a previous mapping- Parameters:
mappingFn- a mapping function
-
getType
Returns a type ofthiscontext -
getRawType
Returns a raw type ofthiscontext -
getAnnotatedType
Returns an annotated type ofthiscontext -
getAnnotations
Returns an array of annotations ofthiscontext annotated type -
hasAnnotation
Checks whetherthiscontext annotations contain an annotation of a given class -
getAnnotation
Returns an annotation of a given annotation type fromthiscontext annotations ornullif none matches -
getTypeArguments
Returns an array of annotated type arguments forthiscontext -
getTypeArgument
Returns nth annotated type argument ofthiscontext -
getTypeArgumentsCount
public int getTypeArgumentsCount()Returns a number of annotated type arguments forthiscontext -
hasTypeArguments
public boolean hasTypeArguments()Checks whetherthiscontext has any type arguments -
scanTypeArgument
Scans nth type argument and returns a resultingTypeScannerRegistry.Contextobject- Parameters:
n- an index of a type argument to be scanned- Returns:
- a scan result which is a
TypeScannerRegistry.Contextobject
-
getStack
Returns a context stack ofthiscontext -
getArgumentStack
Returns an argument stack ofthiscontext -
scan
Scans a given type and returns a resultingTypeScannerRegistry.Contextobject- Parameters:
type- a type to be scanned- Returns:
- a scan result which is a
TypeScannerRegistry.Contextobject
-
scan
Scans a given annotated type and returns a resultingTypeScannerRegistry.Contextobject- Parameters:
annotatedType- an annotated type to be scanned- Returns:
- a scan result which is a
TypeScannerRegistry.Contextobject
-
push
Pushesthiscontext onto a context stack and returns a new context- Parameters:
annotatedType- an annotated type to be pushed onto a context stack- Returns:
- a context after an annotated type has been pushed onto a stack
-
getContextValue
Returns a context value if it is present, ornullotherwise -
toString
-