Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package com.fasterxml.jackson.databind.introspect;
  
  
  
  public final class AnnotatedMethod
     extends AnnotatedWithParams
     implements java.io.Serializable
 {
     private static final long serialVersionUID = 1L;
 
     final protected transient Method _method;
 
     // // Simple lazy-caching:
 
     protected Class<?>[] _paramClasses;

    
Field that is used to make JDK serialization work with this object.

Since:
2.1
 
     protected Serialization _serialization;
     
     /*
     /*****************************************************
     /* Life-cycle
     /*****************************************************
      */
 
     public AnnotatedMethod(Method methodAnnotationMap classAnnAnnotationMap[] paramAnnotations)
     {
         super(classAnnparamAnnotations);
         if (method == null) {
             throw new IllegalArgumentException("Can not construct AnnotatedMethod with null Method");
         }
          = method;
     }

    
Method used for JDK serialization support

Since:
2.1
 
     protected AnnotatedMethod(Serialization ser)
     {
         super(nullnull);
          = null;
          = ser;
     }
    
    
Method that constructs a new instance with settings (annotations, parameter annotations) of this instance, but with different physical java.lang.reflect.Method.
 
     public AnnotatedMethod withMethod(Method m)
     {
         return new AnnotatedMethod(m);
     }
     
     @Override
     public AnnotatedMethod withAnnotations(AnnotationMap ann) {
         return new AnnotatedMethod(ann);
     }
 
     /*
     /*****************************************************
     /* Annotated impl
     /*****************************************************
      */
 
     @Override
     public Method getAnnotated() { return ; }
 
     @Override
     public int getModifiers() { return .getModifiers(); }
 
     @Override
     public String getName() { return .getName(); }

    
For methods, this returns declared return type, which is only useful with getters (setters do not return anything; hence "void" type is returned here)
 
     @Override
     public Type getGenericType() {
         return .getGenericReturnType();
     }

    
For methods, this returns declared return type, which is only useful with getters (setters do not usually return anything; hence "void" type is returned here)
 
     @Override
    public Class<?> getRawType() {
        return .getReturnType();
    }

    
As per [JACKSON-468], we need to also allow declaration of local type bindings; mostly it will allow defining bounds.
    @Override
    public JavaType getType(TypeBindings bindings) {
        return getType(bindings.getTypeParameters());
    }
    @Override
    public final Object call() throws Exception {
        return .invoke(null);
    }
    @Override
    public final Object call(Object[] argsthrows Exception {
        return .invoke(nullargs);
    }
    @Override
    public final Object call1(Object argthrows Exception {
        return .invoke(nullarg);
    }
    
    /*
    /********************************************************
    /* AnnotatedMember impl
    /********************************************************
     */
    @Override
    public Class<?> getDeclaringClass() { return .getDeclaringClass(); }
    @Override
    public Method getMember() { return ; }
    @Override
    public void setValue(Object pojoObject value)
        throws IllegalArgumentException
    {
        try {
            .invoke(pojovalue);
        } catch (IllegalAccessException e) {
            throw new IllegalArgumentException("Failed to setValue() with method "
                    +getFullName()+": "+e.getMessage(), e);
        } catch (InvocationTargetException e) {
            throw new IllegalArgumentException("Failed to setValue() with method "
                    +getFullName()+": "+e.getMessage(), e);
        }
    }
    @Override
    public Object getValue(Object pojothrows IllegalArgumentException
    {
        try {
            return .invoke(pojo);
        } catch (IllegalAccessException e) {
            throw new IllegalArgumentException("Failed to getValue() with method "
                    +getFullName()+": "+e.getMessage(), e);
        } catch (InvocationTargetException e) {
            throw new IllegalArgumentException("Failed to getValue() with method "
                    +getFullName()+": "+e.getMessage(), e);
        }
    }
    
    /*
    /*****************************************************
    /* Extended API, generic
    /*****************************************************
     */
    @Override
    public int getParameterCount() {
        return getRawParameterTypes().length;
    }
    public String getFullName() {
        return getDeclaringClass().getName() + "#" + getName() + "("
            +getParameterCount()+" params)";
    }
    
    public Class<?>[] getRawParameterTypes()
    {
        if ( == null) {
             = .getParameterTypes();
        }
        return ;
    }
    
    public Type[] getGenericParameterTypes() {
        return .getGenericParameterTypes();
    }
    @Override
    public Class<?> getRawParameterType(int index)
    {
        Class<?>[] types = getRawParameterTypes();
        return (index >= types.length) ? null : types[index];
    }
    @Override
    public Type getGenericParameterType(int index)
    {
        Type[] types = .getGenericParameterTypes();
        return (index >= types.length) ? null : types[index];
    }
    public Class<?> getRawReturnType() {
        return .getReturnType();
    }
    
    public Type getGenericReturnType() {
        return .getGenericReturnType();
    }
    /*
    /********************************************************
    /* Other
    /********************************************************
     */
    @Override
    public String toString()
    {
        return "[method "+getFullName()+"]";
    }
    /*
    /**********************************************************
    /* JDK serialization handling
    /**********************************************************
     */
    Object writeReplace() {
        return new AnnotatedMethod(new Serialization());
    }
    Object readResolve() {
        Class<?> clazz = .;
        try {
            Method m = clazz.getDeclaredMethod(.,
                    .);
            // 06-Oct-2012, tatu: Has "lost" its security override, may need to force back
            if (!m.isAccessible()) {
                ClassUtil.checkAndFixAccess(m);
            }
            return new AnnotatedMethod(mnullnull);
        } catch (Exception e) {
            throw new IllegalArgumentException("Could not find method '"+.
                        +"' from Class '"+clazz.getName());
        }
    }
    
    
Helper class that is used as the workaround to persist Field references. It basically just stores declaring class and field name.
    private final static class Serialization
        implements java.io.Serializable
    {
        private static final long serialVersionUID = 1L;
        protected Class<?> clazz;
        protected String name;
        protected Class<?>[] args;
        public Serialization(Method setter) {
             = setter.getDeclaringClass();
             = setter.getName();
             = setter.getParameterTypes();
        }
    }
New to GrepCode? Check out our FAQ X