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
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionConstructorParameter(Annotation[] annotations, Type parameterType, Type genericType, boolean isPrimitive, int parameterIndex, String name, StaticInjectAnnotationProcessorFactory[] processorFactories, DefaultInjectionStrategy defaultInjectionStrategy) -
Method Summary
Modifier and TypeMethodDescriptionfinal AnnotatedElementfinal StringgetName()intfinal TypegetType()getVia()Class<? extends ViaProviderType>booleanbooleanisOptional(InjectAnnotationProcessor annotationProcessor) booleanstatic ConstructorParameterof(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:
getAnnotatedElementin interfaceInjectableElement- Returns:
- Underlying annotated element
-
getType
- Specified by:
getTypein interfaceInjectableElement- Returns:
- Type of injectable mapped to wrapper class
-
getName
- Specified by:
getNamein interfaceInjectableElement- Returns:
- Name for injection
-
getSource
- Specified by:
getSourcein interfaceInjectableElement- Returns:
- Via annotation or null
-
getVia
- Specified by:
getViain interfaceInjectableElement- Returns:
- Via annotation or null
-
getViaProviderType
- Specified by:
getViaProviderTypein interfaceInjectableElement
-
hasDefaultValue
public boolean hasDefaultValue()- Specified by:
hasDefaultValuein interfaceInjectableElement- Returns:
- true, if a default value is set
-
getDefaultValue
- Specified by:
getDefaultValuein interfaceInjectableElement- Returns:
- Default value or null
-
isOptional
- Specified by:
isOptionalin interfaceInjectableElement- Parameters:
annotationProcessor- Annotation processor- Returns:
trueif the element is optional otherwisefalse
-