Class ConstructorParameter

java.lang.Object
org.apache.sling.models.impl.model.ConstructorParameter
All Implemented Interfaces:
InjectableElement

public class ConstructorParameter extends Object
Constructor parameters aren't normally accessible using the AnnotatedElement. This class acts as a facade to ease compatibility with field and method injection.
  • Constructor Details

    • ConstructorParameter

      public ConstructorParameter(Annotation[] annotations, Type parameterType, Type genericType, boolean isPrimitive, int parameterIndex, String name, org.apache.sling.models.spi.injectorspecific.StaticInjectAnnotationProcessorFactory[] processorFactories, org.apache.sling.models.annotations.DefaultInjectionStrategy defaultInjectionStrategy)
  • Method Details

    • of

      public static ConstructorParameter of(Parameter parameter, int parameterIndex, org.apache.sling.models.spi.injectorspecific.StaticInjectAnnotationProcessorFactory[] processorFactories, org.apache.sling.models.annotations.DefaultInjectionStrategy defaultInjectionStrategy)
      Try to extract parameter names according to https://openjdk.org/jeps/118 (requires javac flag -parameters)
      Parameters:
      parameter -
      parameterIndex -
      processorFactories -
      defaultInjectionStrategy -
    • getParameterType

      public Type getParameterType()
    • isPrimitive

      public boolean isPrimitive()
      Returns:
      true if original type of injectable is a primitive type
    • getParameterIndex

      public int getParameterIndex()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getAnnotatedElement

      public final AnnotatedElement getAnnotatedElement()
      Specified by:
      getAnnotatedElement in interface InjectableElement
      Returns:
      Underlying annotated element
    • getType

      public final Type getType()
      Specified by:
      getType in interface InjectableElement
      Returns:
      Type of injectable mapped to wrapper class
    • getName

      public final String getName()
      Specified by:
      getName in interface InjectableElement
      Returns:
      Name for injection
    • getSource

      public String getSource()
      Specified by:
      getSource in interface InjectableElement
      Returns:
      Via annotation or null
    • getVia

      public String getVia()
      Specified by:
      getVia in interface InjectableElement
      Returns:
      Via annotation or null
    • getViaProviderType

      public Class<? extends org.apache.sling.models.annotations.ViaProviderType> getViaProviderType()
      Specified by:
      getViaProviderType in interface InjectableElement
    • hasDefaultValue

      public boolean hasDefaultValue()
      Specified by:
      hasDefaultValue in interface InjectableElement
      Returns:
      true, if a default value is set
    • getDefaultValue

      public Object getDefaultValue()
      Specified by:
      getDefaultValue in interface InjectableElement
      Returns:
      Default value or null
    • isOptional

      public boolean isOptional(org.apache.sling.models.spi.injectorspecific.InjectAnnotationProcessor annotationProcessor)
      Specified by:
      isOptional in interface InjectableElement
      Parameters:
      annotationProcessor - Annotation processor
      Returns:
      true if the element is optional otherwise false