Interface Qualifier<T>

Type Parameters:
T - The qualifier type
All Known Implementing Classes:
AnyQualifier, ClosestTypeArgumentQualifier, ConsumesMediaTypeQualifier, EachBeanQualifier, FilteringQualifier, InterceptorBindingQualifier, MatchArgumentQualifier, 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 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()
    • doesQualify

      default boolean doesQualify(Class<T> beanType, BeanType<T> candidate)
      Check if the candidate qualifies.
      Parameters:
      beanType - The bean type
      candidate - The candidate
      Returns:
      true if matches
      Since:
      4.2.0
    • doesQualify

      default boolean doesQualify(Class<T> beanType, Collection<? extends BeanType<T>> candidates)
      Check if at least one candidate qualifies.
      Parameters:
      beanType - The bean type
      candidates - The candidates
      Returns:
      true if qualifies
      Since:
      4.2.0
    • filter

      default <BT extends BeanType<T>> Collection<BT> filter(Class<T> beanType, Collection<BT> candidates)
      Filter the candidates.
      Type Parameters:
      BT - The bean type subclass
      Parameters:
      beanType - The bean type
      candidates - The candidates
      Returns:
      The filtered candidates
      Since:
      4.2.0