public DelegatingDeserializer(JsonDeserializer<?> d) { super(d.handledType()); _delegatee = d; }
@Override public Class<?> handledType() { return _deserializer.handledType(); }
@Override public Class<?> handledType() { return _delegateDeserializer.handledType(); }
/** * Configure custom deserializers. Each deserializer is registered for the type * returned by {@link JsonDeserializer#handledType()}, which must not be {@code null}. * @since 4.3 * @see #deserializersByType(Map) */ public Jackson2ObjectMapperBuilder deserializers(JsonDeserializer<?>... deserializers) { for (JsonDeserializer<?> deserializer : deserializers) { Class<?> handledType = deserializer.handledType(); if (handledType == null || handledType == Object.class) { throw new IllegalArgumentException("Unknown handled type in " + deserializer.getClass().getName()); } this.deserializers.put(deserializer.handledType(), deserializer); } return this; }
/** * Configure custom deserializers. Each deserializer is registered for the type * returned by {@link JsonDeserializer#handledType()}, which must not be {@code null}. * @since 4.3 * @see #deserializersByType(Map) */ public Jackson2ObjectMapperBuilder deserializers(JsonDeserializer<?>... deserializers) { for (JsonDeserializer<?> deserializer : deserializers) { Class<?> handledType = deserializer.handledType(); if (handledType == null || handledType == Object.class) { throw new IllegalArgumentException("Unknown handled type in " + deserializer.getClass().getName()); } this.deserializers.put(deserializer.handledType(), deserializer); } return this; }
/** * Helper method used to indicate a problem with input in cases where more * specific <code>reportXxx()</code> method was not available. * * @since 2.9 */ public <T> T reportInputMismatch(JsonDeserializer<?> src, String msg, Object... msgArgs) throws JsonMappingException { msg = _format(msg, msgArgs); throw MismatchedInputException.from(getParser(), src.handledType(), msg); }
@Override public JsonDeserializer<?> createContextual(DeserializationContext ctxt, BeanProperty property) throws JsonMappingException { JavaType vt = ctxt.constructType(_delegatee.handledType()); JsonDeserializer<?> del = ctxt.handleSecondaryContextualization(_delegatee, property, vt); if (del == _delegatee) { return this; } return newDelegatingInstance(del); }
/** * Method for deserializers to call * when the token encountered was of type different than what <b>should</b> * be seen at that position, usually within a sequence of expected tokens. * Note that this method will throw a {@link JsonMappingException} and no * recovery is attempted (via {@link DeserializationProblemHandler}, as * problem is considered to be difficult to recover from, in general. * * @since 2.9 */ public void reportWrongTokenException(JsonDeserializer<?> deser, JsonToken expToken, String msg, Object... msgArgs) throws JsonMappingException { msg = _format(msg, msgArgs); throw wrongTokenException(getParser(), deser.handledType(), expToken, msg); }
/** * Method that deserializer may call if it is called to do an update ("merge") * but deserializer operates on a non-mergeable type. Although this should * usually be caught earlier, sometimes it may only be caught during operation * and if so this is the method to call. * Note that if {@link MapperFeature#IGNORE_MERGE_FOR_UNMERGEABLE} is enabled, * this method will simply return null; otherwise {@link InvalidDefinitionException} * will be thrown. * * @since 2.9 */ public <T> T reportBadMerge(JsonDeserializer<?> deser) throws JsonMappingException { if (isEnabled(MapperFeature.IGNORE_MERGE_FOR_UNMERGEABLE)) { return null; } JavaType type = constructType(deser.handledType()); String msg = String.format("Invalid configuration: values of type %s cannot be merged", type); throw InvalidDefinitionException.from(getParser(), msg, type); }
/** * Offlined method called to handle "native" Object Id that has been read * and known to be associated with given deserialized POJO. * * @since 2.3 */ protected Object _handleTypedObjectId(JsonParser p, DeserializationContext ctxt, Object pojo, Object rawId) throws IOException { // One more challenge: type of id may not be type of property we are expecting // later on; specifically, numeric ids vs Strings. JsonDeserializer<Object> idDeser = _objectIdReader.getDeserializer(); final Object id; // Ok, this is bit ridiculous; let's see if conversion is needed: if (idDeser.handledType() == rawId.getClass()) { // nope: already same type id = rawId; } else { id = _convertObjectId(p, ctxt, rawId, idDeser); } ReadableObjectId roid = ctxt.findObjectId(id, _objectIdReader.generator, _objectIdReader.resolver); roid.bindItem(pojo); // also: may need to set a property value as well SettableBeanProperty idProp = _objectIdReader.idProperty; if (idProp != null) { return idProp.setAndReturn(pojo, id); } return pojo; }
return NullsFailProvider.constructForRootValue(ctxt.constructType(valueDeser.handledType()));
private static Class<?> _figureType(JsonDeserializer<?> deser) { Class<?> cls = deser.handledType(); if (cls != null) { return cls; } return Object.class; }
public DelegatingDeserializer(JsonDeserializer<?> d) { super(d.handledType()); _delegatee = d; }
private static Class<?> _figureType(JsonDeserializer<?> deser) { Class<?> cls = deser.handledType(); if (cls != null) { return cls; } return Object.class; }
@Override public Class<?> handledType() { return _delegateDeserializer.handledType(); }
@Override public Class<?> handledType() { return _delegateDeserializer.handledType(); }
private static Class<?> _figureType(JsonDeserializer<?> deser) { Class<?> cls = deser.handledType(); if (cls != null) { return cls; } return Object.class; }
@Override public Class<?> handledType() { return _deserializer.handledType(); }
/** * Helper method used to indicate a problem with input in cases where more * specific <code>reportXxx()</code> method was not available. * * @since 2.9 */ public <T> T reportInputMismatch(JsonDeserializer<?> src, String msg, Object... msgArgs) throws JsonMappingException { msg = _format(msg, msgArgs); throw MismatchedInputException.from(getParser(), src.handledType(), msg); }
@Override public JsonDeserializer<?> createContextual(DeserializationContext ctxt, BeanProperty property) throws JsonMappingException { // 15-Nov-2017, tatu: Important -- MUST contextualize thing we delegate to JavaType vt = ctxt.constructType(_delegatee.handledType()); JsonDeserializer<?> del = ctxt.handleSecondaryContextualization(_delegatee, property, vt); return new XmlTextDeserializer(_verifyDeserType(del), _xmlTextPropertyIndex); }