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>

public static final class TypeScannerRegistry.Context<R> extends Object
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 Details

    • withContextValue

      public TypeScannerRegistry.Context<R> withContextValue(Object value)
      Sets a context value to this context
      Parameters:
      value - a context value
    • withMapping

      public TypeScannerRegistry.Context<R> withMapping(TypeScannerRegistry.Mapping<R> mappingFn)
      Sets a mapping that defines how TypeScannerRegistry.Context value should be retrieved from this TypeScannerRegistry.Context<R>
      Parameters:
      mappingFn - a mapping function
    • withMapping

      Adds a mapping that defines how TypeScannerRegistry.Context value should be retrieved from a TypeScannerRegistry.Context<R> and a previous mapping
      Parameters:
      mappingFn - a mapping function
    • getType

      public Type getType()
      Returns a type of this context
    • getRawType

      public Class<?> getRawType()
      Returns a raw type of this context
    • getAnnotatedType

      public AnnotatedType getAnnotatedType()
      Returns an annotated type of this context
    • getAnnotations

      public Annotation[] getAnnotations()
      Returns an array of annotations of this context annotated type
    • hasAnnotation

      public boolean hasAnnotation(Class<? extends Annotation> clazz)
      Checks whether this context annotations contain an annotation of a given class
    • getAnnotation

      public <A extends Annotation> A getAnnotation(Class<A> clazz)
      Returns an annotation of a given annotation type from this context annotations or null if none matches
    • getTypeArguments

      public AnnotatedType[] getTypeArguments()
      Returns an array of annotated type arguments for this context
    • getTypeArgument

      public AnnotatedType getTypeArgument(int n)
      Returns nth annotated type argument of this context
    • getTypeArgumentsCount

      public int getTypeArgumentsCount()
      Returns a number of annotated type arguments for this context
    • hasTypeArguments

      public boolean hasTypeArguments()
      Checks whether this context has any type arguments
    • scanTypeArgument

      public <X extends R> X scanTypeArgument(int n)
      Scans nth type argument and returns a resulting TypeScannerRegistry.Context object
      Parameters:
      n - an index of a type argument to be scanned
      Returns:
      a scan result which is a TypeScannerRegistry.Context object
    • getStack

      public TypeScannerRegistry.Context<R>[] getStack()
      Returns a context stack of this context
    • getArgumentStack

      public AnnotatedType[] getArgumentStack()
      Returns an argument stack of this context
    • scan

      public R scan(Type type)
      Scans a given type and returns a resulting TypeScannerRegistry.Context object
      Parameters:
      type - a type to be scanned
      Returns:
      a scan result which is a TypeScannerRegistry.Context object
    • scan

      public R scan(AnnotatedType annotatedType)
      Scans a given annotated type and returns a resulting TypeScannerRegistry.Context object
      Parameters:
      annotatedType - an annotated type to be scanned
      Returns:
      a scan result which is a TypeScannerRegistry.Context object
    • push

      public TypeScannerRegistry.Context<R> push(AnnotatedType annotatedType)
      Pushes this context 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

      public Object getContextValue()
      Returns a context value if it is present, or null otherwise
    • toString

      public String toString()
      Overrides:
      toString in class Object