Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package com.fasterxml.jackson.module.afterburner.deser;
  
  import java.util.*;
  
 
 {
    
Names of properties being deserialized, in ordered they are expected to have been written (as per serialization settings); used for speculative order-based optimizations
 
     protected final SerializedString[] _orderedPropertyNames;

    
Properties matching names in _orderedPropertyNames, assigned after resolution when property instances are finalized.
 
     
     /*
     /**********************************************************
     /* Life-cycle, construction, initialization
     /**********************************************************
      */
     
     {
         super(srcfalse);
         final int len = props.size();
          = new SerializedString[len];
         for (int i = 0; i < len; ++i) {
             [i] = new SerializedString(props.get(i).getName());
         }
     }
 
     protected SuperSonicBeanDeserializer(SuperSonicBeanDeserializer srcboolean ignoreAllUnknown)
     {
         super(srcignoreAllUnknown);
          = src._orderedProperties;
          = src._orderedPropertyNames;
     }
     
     @Override
     {
         return new SuperSonicBeanDeserializer(thistrue);
     }
 
     /*
     /**********************************************************
     /* BenaDeserializer overrides
     /**********************************************************
      */

    
This method is overridden as we need to know expected order of properties.
 
     @Override
     public void resolve(DeserializationConfig configDeserializerProvider provider)
         throws JsonMappingException
     {
         super.resolve(configprovider);
         /* Ok, now; need to find actual property instances to go with order
          * defined based on property names.
          */
         int len = .;
         ArrayList<SettableBeanPropertyprops = new ArrayList<SettableBeanProperty>(len);
         int i = 0;
         
         for (; i < len; ++i) {
             SettableBeanProperty prop = .find([i].toString());
             if (prop == null) {
                 break;
             }
             props.add(prop);
         }
         // should usually get at least one property; let's for now consider it an error if not
         // (may need to revisit in future)
         if (i == 0) {
             throw new IllegalStateException("Afterburner internal error: BeanDeserializer for "
                     ++" has no properties that match expected ordering -- can not create optimized deserializer");
         }
          = props.toArray(new SettableBeanProperty[props.size()]);
     }
 
    // much of below is cut'n pasted from BeanSerializer
    @Override
    public Object deserialize(JsonParser jpDeserializationContext ctxtObject bean)
        throws IOExceptionJsonProcessingException
    {
        if ( != null) {
            injectValues(ctxtbean);
        }
        if ( != null) {
            return deserializeWithUnwrapped(jpctxtbean);
        }
        if ( != null) {
            return deserializeWithExternalTypeId(jpctxtbean);
        }
        JsonToken t = jp.getCurrentToken();
        SettableBeanProperty prop = [0];
        // First: verify that first name is expected
        if (t == .) {
            if (!jp.nextFieldName([0])) {
                return super.deserialize(jp,  ctxtbean);
            }
            t = jp.nextToken();
        } else if (t != . || !prop.getName().equals(jp.getCurrentName())) {
            return super.deserialize(jp,  ctxtbean);
        }
        // and deserialize
        jp.nextToken();
        try {
            prop.deserializeAndSet(jpctxtbean);
        } catch (Exception e) {
            wrapAndThrow(ebeanprop.getName(), ctxt);
        }
        // then rest of properties
        for (int i = 1, len = .i < len; ++i) {
            prop = [i];
            if (!jp.nextFieldName([i])) { // miss...
                if (jp.getCurrentToken() == .) {
                    break;
                }
                // we likely point to FIELD_NAME, so can just call parent impl
                return super.deserialize(jpctxtbean);
            }
            jp.nextToken(); // skip field, returns value token
            try {
                prop.deserializeAndSet(jpctxtbean);
            } catch (Exception e) {
                wrapAndThrow(ebeanprop.getName(), ctxt);
            }
        }
        // also, need to ensure we get closing END_OBJECT...
        if (jp.nextToken() != .) {
            return super.deserialize(jpctxtbean);
        }
        return bean;
    }
    // much of below is cut'n pasted from BeanSerializer
    @Override
        throws IOExceptionJsonProcessingException
    {
        if () {
            if ( != null) {
                return deserializeWithUnwrapped(jpctxt);
            }
            if ( != null) {
                return deserializeWithExternalTypeId(jpctxt);
            }
            return deserializeFromObjectUsingNonDefault(jpctxt);
        }
        final Object bean = .createUsingDefault();
        if ( != null) {
            injectValues(ctxtbean);
        }
        JsonToken t = jp.getCurrentToken();
        SettableBeanProperty prop = [0];
        // First: verify that first name is expected
        if (t == .) {
            if (!jp.nextFieldName([0])) {
                return super.deserialize(jp,  ctxtbean);
            }
            t = jp.nextToken();
        } else if (t != . || !prop.getName().equals(jp.getCurrentName())) {
            return super.deserialize(jp,  ctxtbean);
        }
        // and deserialize
        jp.nextToken();
        try {
            prop.deserializeAndSet(jpctxtbean);
        } catch (Exception e) {
            wrapAndThrow(ebeanprop.getName(), ctxt);
        }
        // then rest of properties
        for (int i = 1, len = .i < len; ++i) {
            prop = [i];
            if (!jp.nextFieldName([i])) { // miss...
                if (jp.getCurrentToken() == .) {
                    break;
                }
                // we likely point to FIELD_NAME, so can just call parent impl
                return super.deserialize(jpctxtbean);
            }
            jp.nextToken(); // skip field, returns value token
            try {
                prop.deserializeAndSet(jpctxtbean);
            } catch (Exception e) {
                wrapAndThrow(ebeanprop.getName(), ctxt);
            }
        }
        // also, need to ensure we get closing END_OBJECT...
        if (jp.nextToken() != .) {
            return super.deserialize(jpctxtbean);
        }
        return bean;
    }
New to GrepCode? Check out our FAQ X