Interface Qualifier<T>

Type Parameters:
T - The qualifier type
All Known Implementing Classes:
AnyQualifier, ClosestTypeArgumentQualifier, ConsumesMediaTypeQualifier, InterceptorBindingQualifier, PrimaryQualifier, ProducesMediaTypeQualifier, TypeAnnotationQualifier, TypeArgumentQualifier

public interface Qualifier<T>

Used to qualify which bean to select in the case of multiple possible options.

NOTE: When implementing a custom Qualifier you MUST implement Object.hashCode() and Object.equals(Object) so that the qualifier can be used in comparisons and equality checks

Since:
1.0
Author:
Graeme Rocher
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    The name of the primary annotation class.
  • Method Summary

    Modifier and Type
    Method
    Description
    default boolean
    contains(Qualifier<T> qualifier)
    Whether this qualifier contains the given qualifier.
    default <BT extends BeanType<T>>
    Optional<BT>
    qualify(Class<T> beanType, Stream<BT> candidates)
    Qualify the candidate from the stream of candidates.
    <BT extends BeanType<T>>
    Stream<BT>
    reduce(Class<T> beanType, Stream<BT> candidates)
     
  • Field Details

    • PRIMARY

      static final String PRIMARY
      The name of the primary annotation class.
  • Method Details

    • reduce

      <BT extends BeanType<T>> Stream<BT> reduce(Class<T> beanType, Stream<BT> candidates)
      Type Parameters:
      BT - The bean type subclass
      Parameters:
      beanType - The bean type
      candidates - The candidates
      Returns:
      The qualified candidate or null it cannot be qualified
    • contains

      default boolean contains(Qualifier<T> qualifier)
      Whether this qualifier contains the given qualifier.
      Parameters:
      qualifier - The qualifier
      Returns:
      True it does
    • qualify

      default <BT extends BeanType<T>> Optional<BT> qualify(Class<T> beanType, Stream<BT> candidates)
      Qualify the candidate from the stream of candidates.
      Type Parameters:
      BT - The bean type subclass
      Parameters:
      beanType - The bean type
      candidates - The candidates
      Returns:
      The qualified candidate or Optional.empty()