Class InjectionResolver<U extends Annotation>

  • Type Parameters:
    U - U is the annotation used to identify the injection targets.
    All Implemented Interfaces:
    InjectionResolverQuery
    Direct Known Subclasses:
    MapInjectionResolver

    public abstract class InjectionResolver<U extends Annotation>
    extends Object
    implements InjectionResolverQuery
    Implementation of this abstract class are handling injection resolution for a particular injection annotation {@see Inject} Injection targets are identified by the generic parameter and the constructor of this class. Potential injection targets are fields and methods of the injected type.
    Author:
    Jerome Dochez
    • Constructor Detail

      • InjectionResolver

        public InjectionResolver​(Class<U> type)
        Construct a resolver with a particular injection type
        Parameters:
        type - the injection annotation type
    • Method Detail

      • getSetterMethod

        public Method getSetterMethod​(Method annotated,
                                      U annotation)
        Returns the setter method responsible for setting the resource identified by the passed annotation on the passed annotated method. This is useful when the annotation is specified on the getter for instance (due to external specification requirements for instance) while the setter should be used if values must be set using this injection resolver. By default, the setter method is the annotated method.
        Parameters:
        annotated - is the annotated Method
        annotation - the annotation on the method
        Returns:
        the setter method to use for injecting the annotation identified resource
      • isOptional

        public boolean isOptional​(AnnotatedElement annotated,
                                  U annotation)
        Returns true if the resolution of this injection identified by the passed annotation instance is optional
        Parameters:
        annotated - is the annotated java element Method or Field
        annotation - the injection metadata
        Returns:
        true if the {@see getValue()} can return null without generating a faulty injection operation