Class Parameter

  • All Implemented Interfaces:
    java.lang.reflect.AnnotatedElement
    Direct Known Subclasses:
    Parameter.BeanParameter

    public class Parameter
    extends java.lang.Object
    implements java.lang.reflect.AnnotatedElement
    Method parameter model.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  Parameter.BeanParameter
      Bean Parameter class represents a parameter annotated with BeanParam which in fact represents additional set of parameters.
      private static interface  Parameter.ParamAnnotationHelper<T extends java.lang.annotation.Annotation>  
      static class  Parameter.Source
      Parameter injection sources type.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private Parameter​(java.lang.annotation.Annotation[] markers, java.lang.annotation.Annotation marker, Parameter.Source source, java.lang.String sourceName, java.lang.Class<?> rawType, java.lang.reflect.Type type, boolean encoded, java.lang.String defaultValue)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private static java.util.List<Parameter> create​(java.lang.Class concreteClass, java.lang.Class declaringClass, boolean keepEncoded, java.lang.Class[] parameterTypes, java.lang.reflect.Type[] genericParameterTypes, java.lang.annotation.Annotation[][] parameterAnnotations)  
      static Parameter create​(java.lang.Class concreteClass, java.lang.Class declaringClass, boolean encodeByDefault, java.lang.Class<?> rawType, java.lang.reflect.Type type, java.lang.annotation.Annotation[] annotations)
      Create a parameter model.
      static java.util.List<Parameter> create​(java.lang.Class concreteClass, java.lang.Class declaringClass, java.lang.reflect.Constructor<?> ctor, boolean keepEncoded)
      Create a list of parameter models for a given resource method handler injectable constructor.
      static java.util.List<Parameter> create​(java.lang.Class concreteClass, java.lang.Class declaringClass, java.lang.reflect.Method javaMethod, boolean keepEncoded)
      Create a list of parameter models for a given Java method handling a resource method, sub-resource method or a sub-resource locator.
      private static java.util.Map<java.lang.Class,​Parameter.ParamAnnotationHelper> createParamAnnotationHelperMap()  
      boolean equals​(java.lang.Object o)  
      <T extends java.lang.annotation.Annotation>
      T
      getAnnotation​(java.lang.Class<T> annotationClass)  
      java.lang.annotation.Annotation[] getAnnotations()  
      java.lang.annotation.Annotation[] getDeclaredAnnotations()  
      java.lang.String getDefaultValue()
      Get the default parameter value.
      java.lang.Class<?> getRawType()
      Get raw type information for the parameter.
      Parameter.Source getSource()
      Get the parameter value source type.
      java.lang.annotation.Annotation getSourceAnnotation()
      Get the parameter source annotation.
      java.lang.String getSourceName()
      Get the parameter source name, i.e.
      java.lang.reflect.Type getType()
      Get generic type information for the parameter.
      private static java.lang.String getValue​(java.lang.annotation.Annotation a)  
      boolean hasDefaultValue()
      Check if the parameter has a default value set.
      int hashCode()  
      boolean isAnnotationPresent​(java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass)  
      boolean isEncoded()
      If true, the injected parameter value should remain encoded.
      boolean isQualified()
      Check if the parameter is qualified.
      static Parameter overrideSource​(Parameter original, Parameter.Source source)
      Create new parameter model by overriding source of the original parameter model.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.lang.reflect.AnnotatedElement

        getAnnotationsByType, getDeclaredAnnotation, getDeclaredAnnotationsByType
    • Field Detail

      • LOGGER

        private static final java.util.logging.Logger LOGGER
      • annotations

        private final java.lang.annotation.Annotation[] annotations
      • sourceAnnotation

        private final java.lang.annotation.Annotation sourceAnnotation
      • sourceName

        private final java.lang.String sourceName
      • encoded

        private final boolean encoded
      • defaultValue

        private final java.lang.String defaultValue
      • rawType

        private final java.lang.Class<?> rawType
      • type

        private final java.lang.reflect.Type type
    • Constructor Detail

      • Parameter

        private Parameter​(java.lang.annotation.Annotation[] markers,
                          java.lang.annotation.Annotation marker,
                          Parameter.Source source,
                          java.lang.String sourceName,
                          java.lang.Class<?> rawType,
                          java.lang.reflect.Type type,
                          boolean encoded,
                          java.lang.String defaultValue)
    • Method Detail

      • create

        public static Parameter create​(java.lang.Class concreteClass,
                                       java.lang.Class declaringClass,
                                       boolean encodeByDefault,
                                       java.lang.Class<?> rawType,
                                       java.lang.reflect.Type type,
                                       java.lang.annotation.Annotation[] annotations)
        Create a parameter model.
        Parameters:
        concreteClass - concrete resource method handler implementation class.
        declaringClass - declaring class of the method the parameter belongs to or field that this parameter represents.
        encodeByDefault - flag indicating whether the parameter should be encoded by default or not. Note that a presence of Encoded annotation in the list of the parameter annotations will override any value set in the flag to true.
        rawType - raw Java parameter type.
        type - generic Java parameter type.
        annotations - parameter annotations.
        Returns:
        new parameter model.
      • create

        private static java.util.List<Parameter> create​(java.lang.Class concreteClass,
                                                        java.lang.Class declaringClass,
                                                        boolean keepEncoded,
                                                        java.lang.Class[] parameterTypes,
                                                        java.lang.reflect.Type[] genericParameterTypes,
                                                        java.lang.annotation.Annotation[][] parameterAnnotations)
      • create

        public static java.util.List<Parameter> create​(java.lang.Class concreteClass,
                                                       java.lang.Class declaringClass,
                                                       java.lang.reflect.Constructor<?> ctor,
                                                       boolean keepEncoded)
        Create a list of parameter models for a given resource method handler injectable constructor.
        Parameters:
        concreteClass - concrete resource method handler implementation class.
        declaringClass - class where the method has been declared.
        ctor - injectable constructor of the resource method handler.
        keepEncoded - set to true to disable automatic decoding of all the constructor parameters. (See Encoded.
        Returns:
        a list of constructor parameter models.
      • create

        public static java.util.List<Parameter> create​(java.lang.Class concreteClass,
                                                       java.lang.Class declaringClass,
                                                       java.lang.reflect.Method javaMethod,
                                                       boolean keepEncoded)
        Create a list of parameter models for a given Java method handling a resource method, sub-resource method or a sub-resource locator.
        Parameters:
        concreteClass - concrete resource method handler implementation class.
        declaringClass - the class declaring the handling Java method.
        javaMethod - Java method handling a resource method, sub-resource method or a sub-resource locator.
        keepEncoded - set to true to disable automatic decoding of all the method parameters. (See Encoded.
        Returns:
        a list of handling method parameter models.
      • overrideSource

        public static Parameter overrideSource​(Parameter original,
                                               Parameter.Source source)
        Create new parameter model by overriding source of the original parameter model.
        Parameters:
        original - original parameter model.
        source - new overriding parameter source.
        Returns:
        source-overridden copy of the original parameter.
      • getValue

        private static java.lang.String getValue​(java.lang.annotation.Annotation a)
      • getSourceAnnotation

        public java.lang.annotation.Annotation getSourceAnnotation()
        Get the parameter source annotation.
        Returns:
        parameter source annotation.
      • getSource

        public Parameter.Source getSource()
        Get the parameter value source type.
        Returns:
        parameter value source type.
      • getSourceName

        public java.lang.String getSourceName()
        Get the parameter source name, i.e. value of the parameter source annotation.
        Returns:
        parameter source name.
      • isEncoded

        public boolean isEncoded()
        If true, the injected parameter value should remain encoded.
        Returns:
        true if the parameter value should remain encoded, false otherwise.
      • hasDefaultValue

        public boolean hasDefaultValue()
        Check if the parameter has a default value set.
        Returns:
        true if the default parameter value has been set, false otherwise.
      • getDefaultValue

        public java.lang.String getDefaultValue()
        Get the default parameter value.
        Returns:
        default parameter value or null if no default value has been set for the parameter.
      • getRawType

        public java.lang.Class<?> getRawType()
        Get raw type information for the parameter.
        Returns:
        raw parameter type information.
      • getType

        public java.lang.reflect.Type getType()
        Get generic type information for the parameter.
        Returns:
        generic parameter type information.
      • isQualified

        public boolean isQualified()
        Check if the parameter is qualified.
        Returns:
        true if the parameter is qualified, false otherwise.
      • isAnnotationPresent

        public boolean isAnnotationPresent​(java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass)
        Specified by:
        isAnnotationPresent in interface java.lang.reflect.AnnotatedElement
      • getAnnotation

        public <T extends java.lang.annotation.Annotation> T getAnnotation​(java.lang.Class<T> annotationClass)
        Specified by:
        getAnnotation in interface java.lang.reflect.AnnotatedElement
      • getAnnotations

        public java.lang.annotation.Annotation[] getAnnotations()
        Specified by:
        getAnnotations in interface java.lang.reflect.AnnotatedElement
      • getDeclaredAnnotations

        public java.lang.annotation.Annotation[] getDeclaredAnnotations()
        Specified by:
        getDeclaredAnnotations in interface java.lang.reflect.AnnotatedElement
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object