Package io.activej.types.scanner
Class TypeScannerRegistry<R>
java.lang.Object
io.activej.types.scanner.TypeScannerRegistry<R>
- Type Parameters:
R- a type of mapping result
A registry of
TypeScannerRegistry.Mappings by type
Allows traversing complex annotated types
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classA context that encapsulates aTypeScannerRegistry.Mapping<R>and two stacks (a context stack and an argument stack).static interfaceAn interface that describes howTypeScannerRegistry.Mappingvalue should be retrieved from aTypeScannerRegistry.Context<R>static final record -
Method Summary
Modifier and TypeMethodDescriptionstatic <R> TypeScannerRegistry<R>copyOf(TypeScannerRegistry<R> registry) static <R> TypeScannerRegistry<R>create()Creates a newTypeScannerRegistryscan(TypeScannerRegistry.Context<R> ctx) Scans a context and retrievesTypeScannerRegistryvalue as a resultscanner()Creates a new type scanner with no context valueCreates a new type scanner with a context valuewith(TypeT<?> typeT, TypeScannerRegistry.Mapping<R> fn) Adds a mapping for a given typewith(Type type, TypeScannerRegistry.Mapping<R> fn) Adds a mapping for a given typewithMapping(TypeScannerRegistry.Mapping<R> mappingFn) Adds a mapping that defines howTypeScannerRegistryvalue should be retrieved from aTypeScannerRegistry.Context<R>withMapping(BiFunction<TypeScannerRegistry.Mapping<R>, TypeScannerRegistry.Context<R>, R> mappingFn) Adds a mapping that defines howTypeScannerRegistryvalue should be retrieved from aTypeScannerRegistry.Context<R>and a mapping that doesscan(Context)
-
Method Details
-
create
Creates a newTypeScannerRegistry- Type Parameters:
R- type of values to be retrieved from the registry- Returns:
- a new instance of
TypeScannerRegistry
-
copyOf
-
with
Adds a mapping for a given type- Parameters:
typeT- a type tokenfn- a mapping token to be added for a given type
-
with
Adds a mapping for a given type- Parameters:
type- a typefn- a mapping to be added for a given type
-
withMapping
Adds a mapping that defines howTypeScannerRegistryvalue should be retrieved from aTypeScannerRegistry.Context<R>- Parameters:
mappingFn- a mapping function
-
withMapping
public TypeScannerRegistry<R> withMapping(BiFunction<TypeScannerRegistry.Mapping<R>, TypeScannerRegistry.Context<R>, R> mappingFn) Adds a mapping that defines howTypeScannerRegistryvalue should be retrieved from aTypeScannerRegistry.Context<R>and a mapping that doesscan(Context)- Parameters:
mappingFn- a mapping function
-
scanner
Creates a new type scanner with no context value- Returns:
- a new instance of
TypeScanner
-
scanner
Creates a new type scanner with a context value- Parameters:
contextValue- a context value of this type scanner, possiblynull- Returns:
- a new instance of
TypeScanner
-
scan
Scans a context and retrievesTypeScannerRegistryvalue as a result- Parameters:
ctx- a scan context- Returns:
TypeScannerRegistryvalue retrieved as a result of scan
-