Package io.micronaut.context
Interface Qualifier<T>
- Type Parameters:
T
- The qualifier type
- All Known Implementing Classes:
AnyQualifier
,ClosestTypeArgumentQualifier
,ConsumesMediaTypeQualifier
,FilteringQualifier
,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
-
Method Summary
Modifier and TypeMethodDescriptiondefault boolean
Whether this qualifier contains the given qualifier.default boolean
doesQualify
(Class<T> beanType, BeanType<T> candidate) Check if the candidate qualifies.default boolean
doesQualify
(Class<T> beanType, Collection<? extends BeanType<T>> candidates) Check if at least one candidate qualifies.default <BT extends BeanType<T>>
Collection<BT>filter
(Class<T> beanType, Collection<BT> candidates) Filter the candidates.Qualify the candidate from the stream of candidates.
-
Field Details
-
PRIMARY
The name of the primary annotation class.
-
-
Method Details
-
reduce
- Type Parameters:
BT
- The bean type subclass- Parameters:
beanType
- The bean typecandidates
- The candidates- Returns:
- The qualified candidate or null it cannot be qualified
-
contains
Whether this qualifier contains the given qualifier.- Parameters:
qualifier
- The qualifier- Returns:
- True it does
-
qualify
Qualify the candidate from the stream of candidates.- Type Parameters:
BT
- The bean type subclass- Parameters:
beanType
- The bean typecandidates
- The candidates- Returns:
- The qualified candidate or
Optional.empty()
-
doesQualify
Check if the candidate qualifies.- Parameters:
beanType
- The bean typecandidate
- The candidate- Returns:
- true if matches
- Since:
- 4.2.0
-
doesQualify
Check if at least one candidate qualifies.- Parameters:
beanType
- The bean typecandidates
- 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 typecandidates
- The candidates- Returns:
- The filtered candidates
- Since:
- 4.2.0
-