Interface Binding


  • public interface Binding
    Bindings represent targets where values can be injected into an instance. This can be a field or one of the parameters of a method or constructor.

    Target

    The target of a binding is determined by the AccessibleObject and the given Parameter, it can be:
    • A constructor. The parameter indicates which constructor parameter is the target.
    • A method. The parameter indicates which method parameter is the target.
    • A field. Parameter is null.
    • An owner class. In order to access non-static methods and fields the owner class is required as a binding. Both the parameter and the accessible object are null in this case.
    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      java.lang.reflect.AccessibleObject getAccessibleObject()
      Returns the target AccessibleObject for the binding.
      default java.lang.reflect.AnnotatedElement getAnnotatedElement()
      Returns the associated AnnotatedElement for this binding.
      java.lang.reflect.Parameter getParameter()
      Returns the Parameter when the AccessibleObject is a constructor or a method.
      java.util.Set<java.lang.annotation.Annotation> getQualifiers()
      Returns the qualifiers on the injection target.
      java.lang.reflect.Type getType()
      Returns the Type of the injection target.
      boolean isOptional()
      Returns whether this target accepts null as an injection value.
    • Method Detail

      • getType

        java.lang.reflect.Type getType()
        Returns the Type of the injection target.
        Returns:
        the Type of the injection target, never null
      • getQualifiers

        java.util.Set<java.lang.annotation.Annotation> getQualifiers()
        Returns the qualifiers on the injection target.
        Returns:
        a set of qualifier annotations, never null and never contains null
      • isOptional

        boolean isOptional()
        Returns whether this target accepts null as an injection value. Normally null is rejected with UnsatisfiedResolutionException, but optional targets treat null differently. If the target is a method or constructor parameters, null is simply provided, leaving it up to the receiver to deal with the null. For fields, the injection is skipped leaving its default value intact.
        Returns:
        true if the target is optional, otherwise false
      • getAccessibleObject

        java.lang.reflect.AccessibleObject getAccessibleObject()
        Returns the target AccessibleObject for the binding. This is null when the binding refers to the declaring class which is required to access a non-static field or method.
        Returns:
        the target @link AccessibleObject} for the binding, can be null
      • getParameter

        java.lang.reflect.Parameter getParameter()
        Returns the Parameter when the AccessibleObject is a constructor or a method. Returns null for fields.
        Returns:
        a Parameter, can be null
      • getAnnotatedElement

        default java.lang.reflect.AnnotatedElement getAnnotatedElement()
        Returns the associated AnnotatedElement for this binding. This is null for owner bindings.
        Returns:
        the associated AnnotatedElement for this binding, can be null