Interface AssistedAnnotationStrategy<P>
-
- Type Parameters:
P- the type of the provider class
- All Known Implementing Classes:
ConfigurableAssistedAnnotationStrategy
public interface AssistedAnnotationStrategy<P>Annotation strategy forAssistedTypeRegistrationExtension. This strategy configures which marker annotation triggers generation of the assisted producer implementation, which argument annotation can be used to indicate arguments, and how to extract argument names from fields, methods and parameters.The strategy also must supply the inject annotation and provider mechanism configured for the associated injector in order for the extension to create an assisted producer implementation that can be injected.
-
-
Method Summary
All Methods Instance Methods Abstract 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.java.lang.Class<P>providerClass()Returns theClassof the provider type that can be used with the associated injector.java.lang.Objectprovision(P provider)Return the result of calling the given providerP.
-
-
-
Method Detail
-
assistedAnnotationClass
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.- Returns:
- an annotation
Classfor the assisted annotation, nevernull
-
isArgument
boolean isArgument(java.lang.reflect.AnnotatedElement annotatedElement)
Checks if the givenAnnotatedElementis annotated as an argument.- Parameters:
annotatedElement- anAnnotatedElement, cannot benull- Returns:
trueif the element was annotated as an argument, otherwisefalse
-
determineArgumentName
java.lang.String determineArgumentName(java.lang.reflect.AccessibleObject accessibleObject) throws MissingArgumentExceptionDetermines 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.- Parameters:
annotation- an argument annotation, can benullwhen not presentaccessibleObject- anAccessibleObject, cannot benull- Returns:
- an argument name, never
null - Throws:
MissingArgumentException- when argument name could not be determined
-
determineArgumentName
java.lang.String determineArgumentName(java.lang.reflect.Parameter parameter) throws MissingArgumentExceptionDetermines 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.- Parameters:
annotation- an argument annotation, can benullwhen not presentparameter- aParameter, cannot benull- Returns:
- an argument name, never
null - Throws:
MissingArgumentException- when argument name could not be determined
-
injectAnnotation
java.lang.annotation.Annotation injectAnnotation()
Returns the inject annotation supported by the associated injector.- Returns:
- an inject annotation supported by the associated injector, never
null
-
providerClass
java.lang.Class<P> providerClass()
Returns theClassof the provider type that can be used with the associated injector.- Returns:
- a provider
Classsupported by the associated injector, nevernull
-
provision
java.lang.Object provision(P provider)
Return the result of calling the given providerP.- Parameters:
provider- a providerP, cannot benull- Returns:
- a result of calling the given provider, can be
null
-
-