Class ConfigurableAssistedAnnotationStrategy<A extends java.lang.annotation.Annotation>

  • Type Parameters:
    A - the argument annotation type
    P - the provider type
    All Implemented Interfaces:
    AssistedAnnotationStrategy

    public class ConfigurableAssistedAnnotationStrategy<A extends java.lang.annotation.Annotation>
    extends java.lang.Object
    implements AssistedAnnotationStrategy
    An implementation of AssistedAnnotationStrategy which can be configured with custom annotations and which extract argument names via the given argument annotation or determines them by parameter, field or method name.
    • Constructor Summary

      Constructors 
      Constructor Description
      ConfigurableAssistedAnnotationStrategy​(java.lang.Class<? extends java.lang.annotation.Annotation> assisted, java.lang.Class<A> argument, java.util.function.Function<java.lang.reflect.AnnotatedElement,​java.lang.String> argumentNameGetter, java.lang.annotation.Annotation inject)
      Constructs a new instance.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Class<? extends java.lang.annotation.Annotation> assistedAnnotationClass()
      Returns the Class of the marker annotation to indicate a producer should be provided by the assisted injection extension.
      java.lang.String determineArgumentName​(java.lang.reflect.AccessibleObject accessibleObject)
      Determines the name of the argument given an argument annotation and an AccessibleObject.
      java.lang.String determineArgumentName​(java.lang.reflect.Parameter parameter)
      Determines the name of the argument given an argument annotation and a Parameter.
      java.lang.annotation.Annotation injectAnnotation()
      Returns the inject annotation supported by the associated injector.
      boolean isArgument​(java.lang.reflect.AnnotatedElement annotatedElement)
      Checks if the given AnnotatedElement is annotated as an argument.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ConfigurableAssistedAnnotationStrategy

        public ConfigurableAssistedAnnotationStrategy​(java.lang.Class<? extends java.lang.annotation.Annotation> assisted,
                                                      java.lang.Class<A> argument,
                                                      java.util.function.Function<java.lang.reflect.AnnotatedElement,​java.lang.String> argumentNameGetter,
                                                      java.lang.annotation.Annotation inject)
        Constructs a new instance.
        Parameters:
        assisted - an assisted annotation Class to use as marker annotation, cannot be null
        argument - an argument annotation Class to use to mark arguments, cannot be null
        argumentNameGetter - a getter Function to extract the argument name from an argument annotation, cannot be null
        inject - an inject Annotation supported by the associated injector to mark producers with, cannot be null
    • Method Detail

      • assistedAnnotationClass

        public java.lang.Class<? extends java.lang.annotation.Annotation> assistedAnnotationClass()
        Description copied from interface: AssistedAnnotationStrategy
        Returns the Class of the marker annotation to indicate a producer should be provided by the assisted injection extension.
        Specified by:
        assistedAnnotationClass in interface AssistedAnnotationStrategy
        Returns:
        an annotation Class for the assisted annotation, never null
      • isArgument

        public boolean isArgument​(java.lang.reflect.AnnotatedElement annotatedElement)
        Description copied from interface: AssistedAnnotationStrategy
        Checks if the given AnnotatedElement is annotated as an argument.
        Specified by:
        isArgument in interface AssistedAnnotationStrategy
        Parameters:
        annotatedElement - an AnnotatedElement, cannot be null
        Returns:
        true if the element was annotated as an argument, otherwise false
      • determineArgumentName

        public java.lang.String determineArgumentName​(java.lang.reflect.AccessibleObject accessibleObject)
        Description copied from interface: AssistedAnnotationStrategy
        Determines the name of the argument given an argument annotation and an AccessibleObject. The AccessibleObject provided is either a method or a field.

        Returning null, although allowed, is considered a fatal problem and will result in an exception indicating the argument name must be provided somehow.

        Specified by:
        determineArgumentName in interface AssistedAnnotationStrategy
        Parameters:
        accessibleObject - an AccessibleObject, cannot be null
        Returns:
        an argument name, never null
      • determineArgumentName

        public java.lang.String determineArgumentName​(java.lang.reflect.Parameter parameter)
                                               throws MissingArgumentException
        Description copied from interface: AssistedAnnotationStrategy
        Determines the name of the argument given an argument annotation and a Parameter.

        Returning null, although allowed, is considered a fatal problem and will result in an exception indicating the argument name must be provided somehow.

        Specified by:
        determineArgumentName in interface AssistedAnnotationStrategy
        Parameters:
        parameter - a Parameter, cannot be null
        Returns:
        an argument name, never null
        Throws:
        MissingArgumentException - when argument name could not be determined
      • injectAnnotation

        public java.lang.annotation.Annotation injectAnnotation()
        Description copied from interface: AssistedAnnotationStrategy
        Returns the inject annotation supported by the associated injector.
        Specified by:
        injectAnnotation in interface AssistedAnnotationStrategy
        Returns:
        an inject annotation supported by the associated injector, never null