Interface AssistedAnnotationStrategy<P>

  • Type Parameters:
    P - the type of the provider class
    All Known Implementing Classes:
    ConfigurableAssistedAnnotationStrategy

    public interface AssistedAnnotationStrategy<P>
    Annotation strategy for AssistedTypeRegistrationExtension. This strategy configures which marker annotation triggers generation of the assisted producer implementation, which argument annotation can be used to indicate arguments, and how to extract argument names from fields, methods and parameters.

    The strategy also must supply the inject annotation and provider mechanism configured for the associated injector in order for the extension to create an assisted producer implementation that can be injected.

    • Method Summary

      All Methods Instance Methods Abstract 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.
      java.lang.Class<P> providerClass()
      Returns the Class of the provider type that can be used with the associated injector.
      java.lang.Object provision​(P provider)
      Return the result of calling the given provider P.
    • Method Detail

      • assistedAnnotationClass

        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.
        Returns:
        an annotation Class for the assisted annotation, never null
      • isArgument

        boolean isArgument​(java.lang.reflect.AnnotatedElement annotatedElement)
        Checks if the given AnnotatedElement is annotated as an argument.
        Parameters:
        annotatedElement - an AnnotatedElement, cannot be null
        Returns:
        true if the element was annotated as an argument, otherwise false
      • determineArgumentName

        java.lang.String determineArgumentName​(java.lang.reflect.AccessibleObject accessibleObject)
                                        throws MissingArgumentException
        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.

        Parameters:
        annotation - an argument annotation, can be null when not present
        accessibleObject - an AccessibleObject, cannot be null
        Returns:
        an argument name, never null
        Throws:
        MissingArgumentException - when argument name could not be determined
      • determineArgumentName

        java.lang.String determineArgumentName​(java.lang.reflect.Parameter parameter)
                                        throws MissingArgumentException
        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.

        Parameters:
        annotation - an argument annotation, can be null when not present
        parameter - a Parameter, cannot be null
        Returns:
        an argument name, never null
        Throws:
        MissingArgumentException - when argument name could not be determined
      • injectAnnotation

        java.lang.annotation.Annotation injectAnnotation()
        Returns the inject annotation supported by the associated injector.
        Returns:
        an inject annotation supported by the associated injector, never null
      • providerClass

        java.lang.Class<P> providerClass()
        Returns the Class of the provider type that can be used with the associated injector.
        Returns:
        a provider Class supported by the associated injector, never null
      • provision

        java.lang.Object provision​(P provider)
        Return the result of calling the given provider P.
        Parameters:
        provider - a provider P, cannot be null
        Returns:
        a result of calling the given provider, can be null