public class Qualifiers
extends java.lang.Object
Bean
qualifiers.Constructor and Description |
---|
Qualifiers() |
Modifier and Type | Method and Description |
---|---|
static <T> Qualifier<T> |
any()
Allows looking up the first matching instance.
|
static <T> Qualifier<T> |
byAnnotation(java.lang.annotation.Annotation annotation)
Build a qualifier for the given annotation.
|
static <T> Qualifier<T> |
byAnnotation(AnnotationMetadata metadata,
java.lang.Class<? extends java.lang.annotation.Annotation> type)
Build a qualifier for the given annotation.
|
static <T> Qualifier<T> |
byAnnotation(AnnotationMetadata metadata,
java.lang.String type)
Build a qualifier for the given annotation.
|
static <T> Qualifier<T> |
byAnnotationSimple(AnnotationMetadata metadata,
java.lang.String type)
Build a qualifier for the given annotation.
|
static <T> Qualifier<T> |
byExactTypeArgumentName(java.lang.String typeName)
Build a qualifier for the given generic type argument name.
|
static <T> Qualifier<T> |
byInterceptorBinding(AnnotationMetadata annotationMetadata)
Reduces bean definitions by the given interceptor binding.
|
static <T> Qualifier<T> |
byInterceptorBinding(java.util.Collection<java.lang.String> bindingAnnotationNames)
Reduces bean definitions by the given interceptor binding.
|
static <T> Qualifier<T> |
byName(java.lang.String name)
Build a qualifier for the given name.
|
static <T> Qualifier<T> |
byQualifiers(Qualifier<T>... qualifiers)
Build a qualifier from other qualifiers.
|
static <T> Qualifier<T> |
byRepeatableAnnotation(AnnotationMetadata metadata,
java.lang.String repeatableType)
Builds a qualifier that uses the given repeatable annotation.
|
static <T> Qualifier<T> |
byStereotype(java.lang.Class<? extends java.lang.annotation.Annotation> stereotype)
Build a qualifier for the given annotation.
|
static <T> Qualifier<T> |
byStereotype(java.lang.String stereotype)
Build a qualifier for the given annotation.
|
static <T> Qualifier<T> |
byType(java.lang.Class... typeArguments)
Build a qualifier for the given generic type arguments.
|
static <T> Qualifier<T> |
byTypeArguments(java.lang.Class... typeArguments)
Build a qualifier for the given generic type arguments.
|
static <T> Qualifier<T> |
byTypeArgumentsClosest(java.lang.Class... typeArguments)
Build a qualifier for the given generic type arguments.
|
static <T> Qualifier<T> |
forArgument(Argument<?> argument)
Build a qualifier for the given argument.
|
public static <T> Qualifier<T> any()
This qualifier results on NonUniqueBeanException
never being thrown as
the first matching instance will be returned.
T
- The generic typeAny
@Nullable public static <T> Qualifier<T> forArgument(@NonNull Argument<?> argument)
T
- The typeargument
- The argumentpublic static <T> Qualifier<T> byQualifiers(Qualifier<T>... qualifiers)
T
- The component typequalifiers
- The qualifierspublic static <T> Qualifier<T> byName(java.lang.String name)
T
- The component typename
- The namepublic static <T> Qualifier<T> byAnnotation(java.lang.annotation.Annotation annotation)
T
- The component typeannotation
- The annotationpublic static <T> Qualifier<T> byAnnotation(AnnotationMetadata metadata, java.lang.Class<? extends java.lang.annotation.Annotation> type)
T
- The component typemetadata
- The metadatatype
- The annotation typepublic static <T> Qualifier<T> byAnnotation(AnnotationMetadata metadata, java.lang.String type)
Build a qualifier for the given annotation. This qualifier will match a candidate under the following circumstances:
T
- The component typemetadata
- The metadatatype
- The annotation typepublic static <T> Qualifier<T> byRepeatableAnnotation(AnnotationMetadata metadata, java.lang.String repeatableType)
Builds a qualifier that uses the given repeatable annotation.
T
- The component typemetadata
- The metadatarepeatableType
- The annotation repeatable type. That is the annotation specified to Repeatable.value()
@Internal public static <T> Qualifier<T> byAnnotationSimple(AnnotationMetadata metadata, java.lang.String type)
Build a qualifier for the given annotation.
Unlike byAnnotation(io.micronaut.core.annotation.AnnotationMetadata, String)
this method will not attempt to pick the qualifier strategy to use at runtime based on the passed annotation name.
T
- The component typemetadata
- The metadatatype
- The annotation typepublic static <T> Qualifier<T> byStereotype(java.lang.Class<? extends java.lang.annotation.Annotation> stereotype)
T
- The component typestereotype
- The stereotypepublic static <T> Qualifier<T> byStereotype(java.lang.String stereotype)
T
- The component typestereotype
- The stereotypepublic static <T> Qualifier<T> byTypeArguments(java.lang.Class... typeArguments)
T
- The component typetypeArguments
- The generic type arguments@NonNull public static <T> Qualifier<T> byExactTypeArgumentName(@NonNull java.lang.String typeName)
T
- The component typetypeName
- The name of the generic type argumentpublic static <T> Qualifier<T> byTypeArgumentsClosest(java.lang.Class... typeArguments)
T
- The component typetypeArguments
- The generic type argumentspublic static <T> Qualifier<T> byType(java.lang.Class... typeArguments)
T
- The component typetypeArguments
- The generic type arguments@NonNull public static <T> Qualifier<T> byInterceptorBinding(@NonNull AnnotationMetadata annotationMetadata)
T
- The bean typeannotationMetadata
- The annotation metadata@NonNull public static <T> Qualifier<T> byInterceptorBinding(@NonNull java.util.Collection<java.lang.String> bindingAnnotationNames)
T
- The bean typebindingAnnotationNames
- The binding annotation names