Class ConfigurableAssistedAnnotationStrategy<A extends java.lang.annotation.Annotation>
- java.lang.Object
-
- org.int4.dirk.extensions.assisted.ConfigurableAssistedAnnotationStrategy<A>
-
- Type Parameters:
A- the argument annotation typeP- the provider type
- All Implemented Interfaces:
AssistedAnnotationStrategy
public class ConfigurableAssistedAnnotationStrategy<A extends java.lang.annotation.Annotation> extends java.lang.Object implements AssistedAnnotationStrategy
An implementation ofAssistedAnnotationStrategywhich can be configured with custom annotations and which extract argument names via the given argument annotation or determines them by parameter, field or method name.
-
-
Constructor Summary
Constructors Constructor Description ConfigurableAssistedAnnotationStrategy(java.lang.Class<? extends java.lang.annotation.Annotation> assisted, java.lang.Class<A> argument, java.util.function.Function<java.lang.reflect.AnnotatedElement,java.lang.String> argumentNameGetter, java.lang.annotation.Annotation inject)Constructs a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Class<? extends java.lang.annotation.Annotation>assistedAnnotationClass()Returns theClassof the marker annotation to indicate a producer should be provided by the assisted injection extension.java.lang.StringdetermineArgumentName(java.lang.reflect.AccessibleObject accessibleObject)Determines the name of the argument given an argument annotation and anAccessibleObject.java.lang.StringdetermineArgumentName(java.lang.reflect.Parameter parameter)Determines the name of the argument given an argument annotation and aParameter.java.lang.annotation.AnnotationinjectAnnotation()Returns the inject annotation supported by the associated injector.booleanisArgument(java.lang.reflect.AnnotatedElement annotatedElement)Checks if the givenAnnotatedElementis annotated as an argument.
-
-
-
Constructor Detail
-
ConfigurableAssistedAnnotationStrategy
public ConfigurableAssistedAnnotationStrategy(java.lang.Class<? extends java.lang.annotation.Annotation> assisted, java.lang.Class<A> argument, java.util.function.Function<java.lang.reflect.AnnotatedElement,java.lang.String> argumentNameGetter, java.lang.annotation.Annotation inject)Constructs a new instance.- Parameters:
assisted- an assisted annotationClassto use as marker annotation, cannot benullargument- an argument annotationClassto use to mark arguments, cannot benullargumentNameGetter- a getterFunctionto extract the argument name from an argument annotation, cannot benullinject- an injectAnnotationsupported by the associated injector to mark producers with, cannot benull
-
-
Method Detail
-
assistedAnnotationClass
public java.lang.Class<? extends java.lang.annotation.Annotation> assistedAnnotationClass()
Description copied from interface:AssistedAnnotationStrategyReturns theClassof the marker annotation to indicate a producer should be provided by the assisted injection extension.- Specified by:
assistedAnnotationClassin interfaceAssistedAnnotationStrategy- Returns:
- an annotation
Classfor the assisted annotation, nevernull
-
isArgument
public boolean isArgument(java.lang.reflect.AnnotatedElement annotatedElement)
Description copied from interface:AssistedAnnotationStrategyChecks if the givenAnnotatedElementis annotated as an argument.- Specified by:
isArgumentin interfaceAssistedAnnotationStrategy- Parameters:
annotatedElement- anAnnotatedElement, cannot benull- Returns:
trueif the element was annotated as an argument, otherwisefalse
-
determineArgumentName
public java.lang.String determineArgumentName(java.lang.reflect.AccessibleObject accessibleObject)
Description copied from interface:AssistedAnnotationStrategyDetermines the name of the argument given an argument annotation and anAccessibleObject. TheAccessibleObjectprovided is either a method or a field.Returning
null, although allowed, is considered a fatal problem and will result in an exception indicating the argument name must be provided somehow.- Specified by:
determineArgumentNamein interfaceAssistedAnnotationStrategy- Parameters:
accessibleObject- anAccessibleObject, cannot benull- Returns:
- an argument name, never
null
-
determineArgumentName
public java.lang.String determineArgumentName(java.lang.reflect.Parameter parameter) throws MissingArgumentExceptionDescription copied from interface:AssistedAnnotationStrategyDetermines the name of the argument given an argument annotation and aParameter.Returning
null, although allowed, is considered a fatal problem and will result in an exception indicating the argument name must be provided somehow.- Specified by:
determineArgumentNamein interfaceAssistedAnnotationStrategy- Parameters:
parameter- aParameter, cannot benull- Returns:
- an argument name, never
null - Throws:
MissingArgumentException- when argument name could not be determined
-
injectAnnotation
public java.lang.annotation.Annotation injectAnnotation()
Description copied from interface:AssistedAnnotationStrategyReturns the inject annotation supported by the associated injector.- Specified by:
injectAnnotationin interfaceAssistedAnnotationStrategy- Returns:
- an inject annotation supported by the associated injector, never
null
-
-