Package org.int4.dirk.library
Class ConfigurableAnnotationStrategy
- java.lang.Object
-
- org.int4.dirk.library.ConfigurableAnnotationStrategy
-
- All Implemented Interfaces:
AnnotationStrategy
public class ConfigurableAnnotationStrategy extends java.lang.Object implements AnnotationStrategy
Implementation ofAnnotationStrategywhich allows configuring one or more annotations used to control injection.
-
-
Constructor Summary
Constructors Constructor Description ConfigurableAnnotationStrategy(java.lang.Class<? extends java.lang.annotation.Annotation> inject, java.lang.Class<? extends java.lang.annotation.Annotation> qualifier, java.lang.Class<? extends java.lang.annotation.Annotation> optional)Constructs a new instance.
-
Method Summary
All Methods Instance Methods Concrete 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.
-
-
-
Constructor Detail
-
ConfigurableAnnotationStrategy
public ConfigurableAnnotationStrategy(java.lang.Class<? extends java.lang.annotation.Annotation> inject, java.lang.Class<? extends java.lang.annotation.Annotation> qualifier, java.lang.Class<? extends java.lang.annotation.Annotation> optional)Constructs a new instance.- Parameters:
inject- an inject annotationClassto use, cannot benullqualifier- a qualifier annotationClassto use, cannot benulloptional- an optional annotationClassto use, can benull
-
-
Method Detail
-
isOptional
public boolean isOptional(java.lang.reflect.AnnotatedElement element)
Description copied from interface:AnnotationStrategyChecks 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.- Specified by:
isOptionalin interfaceAnnotationStrategy- Parameters:
element- anAnnotatedElement, cannot benull- Returns:
trueif the givenAnnotatedElementis optional, otherwisefalse
-
getInjectAnnotations
public java.util.Set<java.lang.annotation.Annotation> getInjectAnnotations(java.lang.reflect.AnnotatedElement element)
Description copied from interface:AnnotationStrategyReturns allAnnotations on the givenAnnotatedElementwhich are inject annotations.- Specified by:
getInjectAnnotationsin interfaceAnnotationStrategy- Parameters:
element- anAnnotatedElement, cannot benull- Returns:
- a modifiable set of
Annotations, nevernullor containsnull, but can be empty
-
getQualifiers
public java.util.Set<java.lang.annotation.Annotation> getQualifiers(java.lang.reflect.AnnotatedElement element)
Description copied from interface:AnnotationStrategyReturns allAnnotations on the givenAnnotatedElementwhich are qualifier annotations.- Specified by:
getQualifiersin interfaceAnnotationStrategy- Parameters:
element- anAnnotatedElement, cannot benull- Returns:
- a modifiable set of
Annotations, nevernullor containsnull, but can be empty
-
isQualifier
public boolean isQualifier(java.lang.annotation.Annotation annotation)
Description copied from interface:AnnotationStrategyChecks if the givenAnnotationis a qualifier annotation.- Specified by:
isQualifierin interfaceAnnotationStrategy- Parameters:
annotation- anAnnotation, cannot benull- Returns:
trueif the given annotation is a qualifier annotation, otherwisefalse
-
-