Package io.micronaut.inject.qualifiers
Class MatchArgumentQualifier<T>
java.lang.Object
io.micronaut.inject.qualifiers.MatchArgumentQualifier<T>
- Type Parameters:
T- The type
- All Implemented Interfaces:
Qualifier<T>
A
Qualifier that filters beans according to the type arguments.- Since:
- 4.6
- Author:
- Denis Stepanov
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> @NonNull MatchArgumentQualifier<T>contravariant(@NonNull Class<T> beanType, @NonNull Argument<?> genericArgument) Finds matches of a type with a contravariant generic type (types that is a super type or are equal to it).static <T> @NonNull MatchArgumentQualifier<T>Finds matches of a type with a covariant generic type (types that extend the type or are equal to it).booleandoesQualify(Class<T> beanType, BeanType<T> candidate) Check if the candidate qualifies.booleandoesQualify(Class<T> beanType, Collection<? extends BeanType<T>> candidates) Check if at least one candidate qualifies.<BT extends BeanType<T>>
Collection<BT>filter(Class<T> beanType, Collection<BT> candidates) Filter the candidates.static <T> MatchArgumentQualifier<T>ofArgument(Argument<?> argument) toString()
-
Method Details
-
ofArgument
-
covariant
@NonNull public static <T> @NonNull MatchArgumentQualifier<T> covariant(@NonNull @NonNull Class<T> beanType, @NonNull @NonNull Argument<?> genericArgument) Finds matches of a type with a covariant generic type (types that extend the type or are equal to it). The generic argument is assignable from the candidate generic type. Use-cases are generic deserializers, readers.Java example:
MyReader<ArrayList<String>> candidate = ...;MyReader<? extends List<String>> aMatch = candidate;- Type Parameters:
T- The bean type- Parameters:
beanType- The type of the beansgenericArgument- The generic argument of the bean type- Returns:
- The qualifier
-
contravariant
@NonNull public static <T> @NonNull MatchArgumentQualifier<T> contravariant(@NonNull @NonNull Class<T> beanType, @NonNull @NonNull Argument<?> genericArgument) Finds matches of a type with a contravariant generic type (types that is a super type or are equal to it). The candidate generic type is assignable from the generic argument. Use-cases are generic serializers, writers.Java example:
MyWriter<String> candidate = ...;MyWriter<? super CharSequence> aMatch = candidate;- Type Parameters:
T- The bean type- Parameters:
beanType- The type of the beansgenericArgument- The generic argument of the bean type- Returns:
- The qualifier
-
reduce
-
doesQualify
Description copied from interface:QualifierCheck if at least one candidate qualifies.- Specified by:
doesQualifyin interfaceQualifier<T>- Parameters:
beanType- The bean typecandidates- The candidates- Returns:
- true if qualifies
-
doesQualify
Description copied from interface:QualifierCheck if the candidate qualifies.- Specified by:
doesQualifyin interfaceQualifier<T>- Parameters:
beanType- The bean typecandidate- The candidate- Returns:
- true if matches
-
filter
Description copied from interface:QualifierFilter the candidates. -
toString
-