Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package com.fasterxml.jackson.databind.deser.impl;
  
  
This concrete sub-class implements Collection or Map property that is indirectly by getting the property value and directly modifying it.
 
 public final class SetterlessProperty
     extends SettableBeanProperty
 {
     private static final long serialVersionUID = 1L;
 
     protected final AnnotatedMethod _annotated;

    
Get method for accessing property value used to access property (of Collection or Map type) to modify.
 
     protected final Method _getter;
 
     public SetterlessProperty(BeanPropertyDefinition propDefJavaType type,
             TypeDeserializer typeDeserAnnotations contextAnnotationsAnnotatedMethod method)
         {
         super(propDeftypetypeDesercontextAnnotations);
          = method;
          = method.getAnnotated();
     }
 
     protected SetterlessProperty(SetterlessProperty srcJsonDeserializer<?> deser) {
         super(srcdeser);
          = src._annotated;
          = src._getter;
     }
 
     protected SetterlessProperty(SetterlessProperty srcString newName) {
         super(srcnewName);
          = src._annotated;
          = src._getter;
     }
 
     @Override
     public SetterlessProperty withName(String newName) {
         return new SetterlessProperty(thisnewName);
     }
     
     @Override
         return new SetterlessProperty(thisdeser);
     }
     
     /*
     /**********************************************************
     /* BeanProperty impl
     /**********************************************************
      */
     
     @Override
     public <A extends Annotation> A getAnnotation(Class<A> acls) {
         return .getAnnotation(acls);
     }
 
     @Override public AnnotatedMember getMember() {  return ; }
 
     /*
     /**********************************************************
     /* Overridden methods
     /**********************************************************
      */
     
     @Override
     public final void deserializeAndSet(JsonParser jpDeserializationContext ctxt,
             Object instance)
         throws IOExceptionJsonProcessingException
     {
         JsonToken t = jp.getCurrentToken();
         if (t == .) {
             /* Hmmh. Is this a problem? We won't be setting anything, so it's
              * equivalent of empty Collection/Map in this case
              */
             return;
         }
 
        // Ok: then, need to fetch Collection/Map to modify:
        Object toModify;
        try {
            toModify = .invoke(instance);
        } catch (Exception e) {
            _throwAsIOE(e);
            return// never gets here
        }
        /* Note: null won't work, since we can't then inject anything
         * in. At least that's not good in common case. However,
         * theoretically the case where we get JSON null might
         * be compatible. If so, implementation could be changed.
         */
        if (toModify == null) {
            throw new JsonMappingException("Problem deserializing 'setterless' property '"+getName()+"': get method returned null");
        }
        .deserialize(jpctxttoModify);
    }
    @Override
    		DeserializationContext ctxtObject instance)
        throws IOExceptionJsonProcessingException
    {
    	deserializeAndSet(jpctxtinstance);
    	return instance;
    }
    
    @Override
    public final void set(Object instanceObject value)
        throws IOException
    {
        throw new UnsupportedOperationException("Should never call 'set' on setterless property");
    }
    @Override
    public Object setAndReturn(Object instanceObject value)
            throws IOException
    {
    	set(instancevalue);
    	return null;
    }
New to GrepCode? Check out our FAQ X