Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package com.fasterxml.jackson.databind.introspect;
  
  
  
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

 
 public final class AnnotatedParameter
     extends AnnotatedMember
 {
     private static final long serialVersionUID = 1L;

    
Member (method, constructor) that this parameter belongs to
 
     protected final AnnotatedWithParams _owner;
    
    
JDK type of the parameter, possibly contains generic type information
 
     protected final Type _type;
    
    
Index of the parameter within argument list
 
     protected final int _index;
     
     /*
     /**********************************************************
     /* Life-cycle
     /**********************************************************
      */
 
     public AnnotatedParameter(AnnotatedWithParams ownerType type,  AnnotationMap annotations,
             int index)
     {
         super(annotations);
          = owner;
          = type;
          = index;
     }
 
     @Override
         if (ann == ) {
             return this;
         }
         return .replaceParameterAnnotations(ann);
     }
 
     /*
     /**********************************************************
     /* Annotated impl
     /**********************************************************
      */

    
Since there is no matching JDK element, this method will always return null
 
     @Override
     public AnnotatedElement getAnnotated() { return null; }

    
Returns modifiers of the constructor, as parameters do not have independent modifiers.
 
     @Override
     public int getModifiers() { return .getModifiers(); }

    
Parameters have no names in bytecode (unlike in source code), will always return empty String ("").
 
     @Override
     public String getName() { return ""; }

    
Accessor for annotations; all annotations associated with parameters are properly passed and accessible.
 
     @Override
     public <A extends Annotation> A getAnnotation(Class<A> acls)
     {
        return ( == null) ? null : .get(acls);
    }
    @Override
    public Type getGenericType() {
        return ;
    }
    @Override
    public Class<?> getRawType()
    {
        if ( instanceof Class<?>) {
            return (Class<?>) ;
        }
        // 14-Mar-2011, tatu: Not optimal, but has to do for now...
        JavaType t = TypeFactory.defaultInstance().constructType();
        return t.getRawClass();
    }
    /*
    /**********************************************************
    /* AnnotatedMember extras
    /**********************************************************
     */
    @Override
    public Class<?> getDeclaringClass() {
        return .getDeclaringClass();
    }
    @Override
    public Member getMember() {
        /* This is bit tricky: since there is no JDK equivalent; can either
         * return null or owner... let's do latter, for now.
         */
        return .getMember();
    }
    @Override
    public void setValue(Object pojoObject valuethrows UnsupportedOperationException
    {
        throw new UnsupportedOperationException("Cannot call setValue() on constructor parameter of "
                +getDeclaringClass().getName());
    }
    @Override
    public Object getValue(Object pojothrows UnsupportedOperationException
    {
        throw new UnsupportedOperationException("Cannot call getValue() on constructor parameter of "
                +getDeclaringClass().getName());
    }
    
    /*
    /**********************************************************
    /* Extended API
    /**********************************************************
     */
    public Type getParameterType() { return ; }

    
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
    public AnnotatedWithParams getOwner() { return ; }
    
    
Accessor for index of this parameter within argument list

Returns:
Index of this parameter within argument list
    public int getIndex() { return ; }
    /*
    /********************************************************
    /* Other
    /********************************************************
     */
    
    @Override
    public String toString()
    {
        return "[parameter #"+getIndex()+", annotations: "++"]";
    }
New to GrepCode? Check out our FAQ X