Class ConstructorParameter
java.lang.Object
org.apache.sling.models.impl.model.ConstructorParameter
- All Implemented Interfaces:
InjectableElement
Constructor parameters aren't normally accessible using the
AnnotatedElement. This class acts as a facade to ease
compatibility with field and method injection.
-
Nested Class Summary
-
Constructor Summary
ConstructorDescriptionConstructorParameter
(Annotation[] annotations, Type parameterType, Type genericType, boolean isPrimitive, int parameterIndex, String name, StaticInjectAnnotationProcessorFactory[] processorFactories, DefaultInjectionStrategy defaultInjectionStrategy) -
Method Summary
Modifier and TypeMethodDescriptionfinal AnnotatedElement
final String
getName()
int
final Type
getType()
getVia()
Class<? extends ViaProviderType>
boolean
boolean
isOptional
(InjectAnnotationProcessor annotationProcessor) boolean
static ConstructorParameter
of
(Parameter parameter, int parameterIndex, StaticInjectAnnotationProcessorFactory[] processorFactories, DefaultInjectionStrategy defaultInjectionStrategy) Try to extract parameter names according to https://openjdk.org/jeps/118 (requires javac flag -parameters)toString()
-
Constructor Details
-
ConstructorParameter
public ConstructorParameter(Annotation[] annotations, Type parameterType, Type genericType, boolean isPrimitive, int parameterIndex, String name, StaticInjectAnnotationProcessorFactory[] processorFactories, DefaultInjectionStrategy defaultInjectionStrategy)
-
-
Method Details
-
of
public static ConstructorParameter of(Parameter parameter, int parameterIndex, StaticInjectAnnotationProcessorFactory[] processorFactories, DefaultInjectionStrategy defaultInjectionStrategy) Try to extract parameter names according to https://openjdk.org/jeps/118 (requires javac flag -parameters)- Parameters:
parameter
-parameterIndex
-processorFactories
-defaultInjectionStrategy
-
-
getParameterType
-
isPrimitive
public boolean isPrimitive()- Returns:
- true if original type of injectable is a primitive type
-
getParameterIndex
public int getParameterIndex() -
toString
-
getAnnotatedElement
- Specified by:
getAnnotatedElement
in interfaceInjectableElement
- Returns:
- Underlying annotated element
-
getType
- Specified by:
getType
in interfaceInjectableElement
- Returns:
- Type of injectable mapped to wrapper class
-
getName
- Specified by:
getName
in interfaceInjectableElement
- Returns:
- Name for injection
-
getSource
- Specified by:
getSource
in interfaceInjectableElement
- Returns:
- Via annotation or null
-
getVia
- Specified by:
getVia
in interfaceInjectableElement
- Returns:
- Via annotation or null
-
getViaProviderType
- Specified by:
getViaProviderType
in interfaceInjectableElement
-
hasDefaultValue
public boolean hasDefaultValue()- Specified by:
hasDefaultValue
in interfaceInjectableElement
- Returns:
- true, if a default value is set
-
getDefaultValue
- Specified by:
getDefaultValue
in interfaceInjectableElement
- Returns:
- Default value or null
-
isOptional
- Specified by:
isOptional
in interfaceInjectableElement
- Parameters:
annotationProcessor
- Annotation processor- Returns:
true
if the element is optional otherwisefalse
-