Package org.int4.dirk.spi.config
Interface AnnotationStrategy
-
public interface AnnotationStrategyStrategy for checking and obtaining annotations relevant to dependency injection.Strategies can either resolve conflicting annotations or report them as a definition problem. It is recommended the problems are reported.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.util.Set<java.lang.annotation.Annotation>getInjectAnnotations(java.lang.reflect.AnnotatedElement element)Returns allAnnotations on the givenAnnotatedElementwhich are inject annotations.java.util.Set<java.lang.annotation.Annotation>getQualifiers(java.lang.reflect.AnnotatedElement element)Returns allAnnotations on the givenAnnotatedElementwhich are qualifier annotations.booleanisOptional(java.lang.reflect.AnnotatedElement element)Checks if the givenAnnotatedElementis optional.booleanisQualifier(java.lang.annotation.Annotation annotation)Checks if the givenAnnotationis a qualifier annotation.
-
-
-
Method Detail
-
getInjectAnnotations
java.util.Set<java.lang.annotation.Annotation> getInjectAnnotations(java.lang.reflect.AnnotatedElement element) throws DefinitionExceptionReturns allAnnotations on the givenAnnotatedElementwhich are inject annotations.- Parameters:
element- anAnnotatedElement, cannot benull- Returns:
- a modifiable set of
Annotations, nevernullor containsnull, but can be empty - Throws:
DefinitionException- when the strategy detects an annotation problem
-
isOptional
boolean isOptional(java.lang.reflect.AnnotatedElement element) throws DefinitionExceptionChecks if the givenAnnotatedElementis optional. If optional and there is no matching dependency, the injector will not thrown an exception but instead will skip injecting fields and will providenullfor parameters. This allows having default values for field injection.- Parameters:
element- anAnnotatedElement, cannot benull- Returns:
trueif the givenAnnotatedElementis optional, otherwisefalse- Throws:
DefinitionException- when the strategy detects an annotation problem
-
getQualifiers
java.util.Set<java.lang.annotation.Annotation> getQualifiers(java.lang.reflect.AnnotatedElement element) throws DefinitionExceptionReturns allAnnotations on the givenAnnotatedElementwhich are qualifier annotations.- Parameters:
element- anAnnotatedElement, cannot benull- Returns:
- a modifiable set of
Annotations, nevernullor containsnull, but can be empty - Throws:
DefinitionException- when the strategy detects an annotation problem
-
isQualifier
boolean isQualifier(java.lang.annotation.Annotation annotation)
Checks if the givenAnnotationis a qualifier annotation.- Parameters:
annotation- anAnnotation, cannot benull- Returns:
trueif the given annotation is a qualifier annotation, otherwisefalse
-
-