Interface AnnotationStrategy

  • All Known Implementing Classes:
    ConfigurableAnnotationStrategy

    public interface AnnotationStrategy
    Strategy for checking and obtaining annotations relevant to dependency injection.

    Strategies can either resolve conflicting annotations or report them as a definition problem. It is recommended the problems are reported.

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      java.util.Set<java.lang.annotation.Annotation> getInjectAnnotations​(java.lang.reflect.AnnotatedElement element)
      Returns all Annotations on the given AnnotatedElement which are inject annotations.
      java.util.Set<java.lang.annotation.Annotation> getQualifiers​(java.lang.reflect.AnnotatedElement element)
      Returns all Annotations on the given AnnotatedElement which are qualifier annotations.
      boolean isOptional​(java.lang.reflect.AnnotatedElement element)
      Checks if the given AnnotatedElement is optional.
      boolean isQualifier​(java.lang.annotation.Annotation annotation)
      Checks if the given Annotation is a qualifier annotation.
    • Method Detail

      • getInjectAnnotations

        java.util.Set<java.lang.annotation.Annotation> getInjectAnnotations​(java.lang.reflect.AnnotatedElement element)
                                                                     throws DefinitionException
        Returns all Annotations on the given AnnotatedElement which are inject annotations.
        Parameters:
        element - an AnnotatedElement, cannot be null
        Returns:
        a modifiable set of Annotations, never null or contains null, but can be empty
        Throws:
        DefinitionException - when the strategy detects an annotation problem
      • isOptional

        boolean isOptional​(java.lang.reflect.AnnotatedElement element)
                    throws DefinitionException
        Checks if the given AnnotatedElement is optional. If optional and there is no matching dependency, the injector will not thrown an exception but instead will skip injecting fields and will provide null for parameters. This allows having default values for field injection.
        Parameters:
        element - an AnnotatedElement, cannot be null
        Returns:
        true if the given AnnotatedElement is optional, otherwise false
        Throws:
        DefinitionException - when the strategy detects an annotation problem
      • getQualifiers

        java.util.Set<java.lang.annotation.Annotation> getQualifiers​(java.lang.reflect.AnnotatedElement element)
                                                              throws DefinitionException
        Returns all Annotations on the given AnnotatedElement which are qualifier annotations.
        Parameters:
        element - an AnnotatedElement, cannot be null
        Returns:
        a modifiable set of Annotations, never null or contains null, but can be empty
        Throws:
        DefinitionException - when the strategy detects an annotation problem
      • isQualifier

        boolean isQualifier​(java.lang.annotation.Annotation annotation)
        Checks if the given Annotation is a qualifier annotation.
        Parameters:
        annotation - an Annotation, cannot be null
        Returns:
        true if the given annotation is a qualifier annotation, otherwise false