Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package com.fasterxml.jackson.databind.deser.std;
  
  import java.util.*;
  
We need a custom deserializer both because java.util.concurrent.ArrayBlockingQueue has no default constructor AND because it has size limit used for constructing underlying storage automatically.
 
     extends CollectionDeserializer
 {
     private static final long serialVersionUID = 5471961369237518580L;
 
     /*
     /**********************************************************
     /* Life-cycle
     /**********************************************************
      */

    
Constructor used when creating contextualized instances.
 
     public ArrayBlockingQueueDeserializer(JavaType collectionType,
             JsonDeserializer<ObjectvalueDeserTypeDeserializer valueTypeDeser,
             ValueInstantiator valueInstantiator,
             JsonDeserializer<ObjectdelegateDeser)
     {
         super(collectionTypevalueDeservalueTypeDeservalueInstantiatordelegateDeser);
     }

    
Copy-constructor that can be used by sub-classes to allow copy-on-write styling copying of settings of an existing instance.
 
         super(src);
     }

    
Fluent-factory method call to construct contextual instance.
 
     @Override
     @SuppressWarnings("unchecked")
             JsonDeserializer<?> vdTypeDeserializer vtd)
     {
         if ((dd == ) && (vd == ) && (vtd == )) {
             return this;
         }
         return new ArrayBlockingQueueDeserializer(,
                 (JsonDeserializer<Object>) vdvtd,
                 , (JsonDeserializer<Object>) dd);
                 
     }
 
     /*
     /**********************************************************
     /* JsonDeserializer API
     /**********************************************************
      */
     
     @SuppressWarnings("unchecked")
     @Override
         throws IOExceptionJsonProcessingException
     {
         if ( != null) {
             return (Collection<Object>) .createUsingDelegate(ctxt,
                     .deserialize(jpctxt));
         }
         if (jp.getCurrentToken() == .) {
             String str = jp.getText();
             if (str.length() == 0) {
                 return (Collection<Object>) .createFromString(ctxtstr);
             }
         }
         return deserialize(jpctxtnull);
     }
 
     @Override
             Collection<Objectresult0)
         throws IOExceptionJsonProcessingException
     {
         // Ok: must point to START_ARRAY (or equivalent)
         if (!jp.isExpectedStartArrayToken()) {
             return handleNonArray(jpctxtnew ArrayBlockingQueue<Object>(1));
        }
        ArrayList<Objecttmp = new ArrayList<Object>();
        
        JsonDeserializer<ObjectvalueDes = ;
        JsonToken t;
        final TypeDeserializer typeDeser = ;
        while ((t = jp.nextToken()) != .) {
            Object value;
            
            if (t == .) {
                value = null;
            } else if (typeDeser == null) {
                value = valueDes.deserialize(jpctxt);
            } else {
                value = valueDes.deserializeWithType(jpctxttypeDeser);
            }
            tmp.add(value);
        }
        if (result0 != null) {
            result0.addAll(tmp);
            return result0;
        }
        return new ArrayBlockingQueue<Object>(tmp.size(), falsetmp);
    }
    @Override
            TypeDeserializer typeDeserializer)
        throws IOExceptionJsonProcessingException
    {
        // In future could check current token... for now this should be enough:
        return typeDeserializer.deserializeTypedFromArray(jpctxt);
    }
New to GrepCode? Check out our FAQ X