xref: /aosp_15_r20/external/jackson-databind/attic/MappingIteratorDeserializer.java (revision 0ed15c778abdfe0f5f51f6133673e1619d6e56e4)
1*0ed15c77SAndroid Build Coastguard Worker package com.fasterxml.jackson.databind.deser.std;
2*0ed15c77SAndroid Build Coastguard Worker 
3*0ed15c77SAndroid Build Coastguard Worker import java.io.IOException;
4*0ed15c77SAndroid Build Coastguard Worker 
5*0ed15c77SAndroid Build Coastguard Worker import com.fasterxml.jackson.core.*;
6*0ed15c77SAndroid Build Coastguard Worker import com.fasterxml.jackson.databind.*;
7*0ed15c77SAndroid Build Coastguard Worker import com.fasterxml.jackson.databind.deser.ContextualDeserializer;
8*0ed15c77SAndroid Build Coastguard Worker 
9*0ed15c77SAndroid Build Coastguard Worker public class MappingIteratorDeserializer
10*0ed15c77SAndroid Build Coastguard Worker     extends StdDeserializer<MappingIterator<Object>>
11*0ed15c77SAndroid Build Coastguard Worker     implements ContextualDeserializer
12*0ed15c77SAndroid Build Coastguard Worker {
13*0ed15c77SAndroid Build Coastguard Worker     private static final long serialVersionUID = 1L;
14*0ed15c77SAndroid Build Coastguard Worker 
15*0ed15c77SAndroid Build Coastguard Worker     protected final JavaType _valueType;
16*0ed15c77SAndroid Build Coastguard Worker 
17*0ed15c77SAndroid Build Coastguard Worker     protected final JsonDeserializer<Object> _valueDeserializer;
18*0ed15c77SAndroid Build Coastguard Worker 
MappingIteratorDeserializer(JavaType valueType)19*0ed15c77SAndroid Build Coastguard Worker     public MappingIteratorDeserializer(JavaType valueType) {
20*0ed15c77SAndroid Build Coastguard Worker         this(valueType, null);
21*0ed15c77SAndroid Build Coastguard Worker     }
22*0ed15c77SAndroid Build Coastguard Worker 
MappingIteratorDeserializer(JavaType valueType, JsonDeserializer<Object> vdeser)23*0ed15c77SAndroid Build Coastguard Worker     protected MappingIteratorDeserializer(JavaType valueType, JsonDeserializer<Object> vdeser) {
24*0ed15c77SAndroid Build Coastguard Worker         super(MappingIterator.class);
25*0ed15c77SAndroid Build Coastguard Worker         _valueType = valueType;
26*0ed15c77SAndroid Build Coastguard Worker         _valueDeserializer = vdeser;
27*0ed15c77SAndroid Build Coastguard Worker     }
28*0ed15c77SAndroid Build Coastguard Worker 
29*0ed15c77SAndroid Build Coastguard Worker     @Override
createContextual(DeserializationContext ctxt, BeanProperty prop)30*0ed15c77SAndroid Build Coastguard Worker     public JsonDeserializer<?> createContextual(DeserializationContext ctxt,
31*0ed15c77SAndroid Build Coastguard Worker             BeanProperty prop) throws JsonMappingException
32*0ed15c77SAndroid Build Coastguard Worker     {
33*0ed15c77SAndroid Build Coastguard Worker         JsonDeserializer<Object> deser = ctxt.findContextualValueDeserializer(_valueType, prop);
34*0ed15c77SAndroid Build Coastguard Worker         return (deser == _valueDeserializer) ? this
35*0ed15c77SAndroid Build Coastguard Worker                 : new MappingIteratorDeserializer(_valueType, deser);
36*0ed15c77SAndroid Build Coastguard Worker     }
37*0ed15c77SAndroid Build Coastguard Worker 
38*0ed15c77SAndroid Build Coastguard Worker     @Override
deserialize(JsonParser p, DeserializationContext ctxt)39*0ed15c77SAndroid Build Coastguard Worker     public MappingIterator<Object> deserialize(JsonParser p,
40*0ed15c77SAndroid Build Coastguard Worker             DeserializationContext ctxt) throws IOException,
41*0ed15c77SAndroid Build Coastguard Worker             JsonProcessingException
42*0ed15c77SAndroid Build Coastguard Worker     {
43*0ed15c77SAndroid Build Coastguard Worker         MappingIterator<Object> mit = new MappingIterator<Object>(_valueType, p, ctxt,
44*0ed15c77SAndroid Build Coastguard Worker                 _valueDeserializer, false, null);
45*0ed15c77SAndroid Build Coastguard Worker         return mit;
46*0ed15c77SAndroid Build Coastguard Worker     }
47*0ed15c77SAndroid Build Coastguard Worker }
48