Class AnnotatedParameter


  • public final class AnnotatedParameter
    extends AnnotatedMember
    Object that represents method parameters, mostly so that associated annotations can be processed conveniently. Note that many of accessors can not return meaningful values since parameters do not have stand-alone JDK objects associated; so access should mostly be limited to checking annotation values which are properly aggregated and included.

    Note: as of version 1.7, this type extends AnnotatedMember, since it behaves like a member for the most part, but earlier it just extended Annotated

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected int _index
      Index of the parameter within argument list
      protected AnnotatedWithParams _owner
      Member (method, constructor) that this parameter belongs to
      protected java.lang.reflect.Type _type
      JDK type of the parameter, possibly contains generic type information
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addOrOverride​(java.lang.annotation.Annotation a)  
      java.lang.reflect.AnnotatedElement getAnnotated()
      Since there is no matching JDK element, this method will always return null
      <A extends java.lang.annotation.Annotation>
      A
      getAnnotation​(java.lang.Class<A> acls)
      Accessor for annotations; all annotations associated with parameters are properly passed and accessible.
      java.lang.Class<?> getDeclaringClass()  
      java.lang.reflect.Type getGenericType()
      Full generic type of the annotated element; definition of what exactly this means depends on sub-class.
      int getIndex()
      Accessor for index of this parameter within argument list
      java.lang.reflect.Member getMember()  
      int getModifiers()
      Returns modifiers of the constructor, as parameters do not have independent modifiers.
      java.lang.String getName()
      Parameters have no names in bytecode (unlike in source code), will always return empty String ("").
      AnnotatedWithParams getOwner()
      Accessor for 'owner' of this parameter; method or constructor that has this parameter as member of its argument list.
      java.lang.reflect.Type getParameterType()  
      java.lang.Class<?> getRawType()
      "Raw" type (type-erased class) of the annotated element; definition of what exactly this means depends on sub-class.
      void setValue​(java.lang.Object pojo, java.lang.Object value)
      Optional method that can be used to assign value of this member on given object, if this is a supported operation for member type.
      java.lang.String toString()  
      AnnotatedParameter withAnnotations​(AnnotationMap ann)
      Fluent factory method that will construct a new instance that uses specified instance annotations instead of currently configured ones.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • _owner

        protected final AnnotatedWithParams _owner
        Member (method, constructor) that this parameter belongs to
        Since:
        1.7
      • _type

        protected final java.lang.reflect.Type _type
        JDK type of the parameter, possibly contains generic type information
      • _index

        protected final int _index
        Index of the parameter within argument list
        Since:
        1.9
    • Method Detail

      • addOrOverride

        public void addOrOverride​(java.lang.annotation.Annotation a)
      • getAnnotated

        public java.lang.reflect.AnnotatedElement getAnnotated()
        Since there is no matching JDK element, this method will always return null
        Specified by:
        getAnnotated in class Annotated
      • getModifiers

        public int getModifiers()
        Returns modifiers of the constructor, as parameters do not have independent modifiers.
        Specified by:
        getModifiers in class Annotated
      • getName

        public java.lang.String getName()
        Parameters have no names in bytecode (unlike in source code), will always return empty String ("").
        Specified by:
        getName in class Annotated
      • getAnnotation

        public <A extends java.lang.annotation.Annotation> A getAnnotation​(java.lang.Class<A> acls)
        Accessor for annotations; all annotations associated with parameters are properly passed and accessible.
        Specified by:
        getAnnotation in class Annotated
      • getGenericType

        public java.lang.reflect.Type getGenericType()
        Description copied from class: Annotated
        Full generic type of the annotated element; definition of what exactly this means depends on sub-class.
        Specified by:
        getGenericType in class Annotated
      • getRawType

        public java.lang.Class<?> getRawType()
        Description copied from class: Annotated
        "Raw" type (type-erased class) of the annotated element; definition of what exactly this means depends on sub-class.
        Specified by:
        getRawType in class Annotated
      • setValue

        public void setValue​(java.lang.Object pojo,
                             java.lang.Object value)
                      throws java.lang.UnsupportedOperationException
        Description copied from class: AnnotatedMember
        Optional method that can be used to assign value of this member on given object, if this is a supported operation for member type.

        This is implemented for fiedlds and single-argument methods; but not for constructor parameters or other types of methods.

        Specified by:
        setValue in class AnnotatedMember
        Throws:
        java.lang.UnsupportedOperationException
      • getParameterType

        public java.lang.reflect.Type getParameterType()
      • getOwner

        public AnnotatedWithParams getOwner()
        Accessor for 'owner' of this parameter; method or constructor that has this parameter as member of its argument list.
        Returns:
        Owner (member or creator) object of this parameter
        Since:
        1.9
      • getIndex

        public int getIndex()
        Accessor for index of this parameter within argument list
        Returns:
        Index of this parameter within argument list
        Since:
        1.9
      • toString

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