protected void _failOnNull(DeserializationContext ctxt) throws IOException { throw InvalidNullException.from(ctxt, null, ctxt.constructType(_valueClass)); }
@Override public void resolve(DeserializationContext ctxt) throws JsonMappingException { _treeDeserializer = ctxt.findRootValueDeserializer(ctxt.constructType(JsonNode.class)); }
/** * Helper method for constructing instantiation exception for specified type, * to indicate that instantiation failed due to missing instantiator * (creator; constructor or factory method). *<p> * Note that most of the time this method should NOT be called; instead, * {@link #handleMissingInstantiator} should be called which will call this method * if necessary. */ public JsonMappingException instantiationException(Class<?> instClass, String msg0) { // Most likely problem with Creator definition, right? JavaType type = constructType(instClass); String msg = String.format("Cannot construct instance of %s: %s", ClassUtil.nameOf(instClass), msg0); return InvalidDefinitionException.from(_parser, msg, type); }
JavaType type = ctxt.constructType(bean.getClass());
@Override public JsonDeserializer<Object> createBuilderBasedDeserializer(DeserializationContext ctxt, JavaType valueType, BeanDescription beanDesc, Class<?> builderClass) throws JsonMappingException { // First: need a BeanDescription for builder class JavaType builderType = ctxt.constructType(builderClass); BeanDescription builderDesc = ctxt.getConfig().introspectForBuilder(builderType); return buildBuilderBasedDeserializer(ctxt, valueType, builderDesc); }
@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 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); }
/** * Helper method for constructing instantiation exception for specified type, * to indicate problem with physically constructing instance of * specified class (missing constructor, exception from constructor) *<p> * Note that most of the time this method should NOT be called directly; instead, * {@link #handleInstantiationProblem} should be called which will call this method * if necessary. */ public JsonMappingException instantiationException(Class<?> instClass, Throwable cause) { // Most likely problem with Creator definition, right? final JavaType type = constructType(instClass); String excMsg; if (cause == null) { excMsg = "N/A"; } else if ((excMsg = ClassUtil.exceptionMessage(cause)) == null) { excMsg = ClassUtil.nameOf(cause.getClass()); } String msg = String.format("Cannot construct instance of %s, problem: %s", ClassUtil.nameOf(instClass), excMsg); InvalidDefinitionException e = InvalidDefinitionException.from(_parser, msg, type); e.initCause(cause); return e; }
return instance; reportBadDefinition(constructType(instClass), String.format( "DeserializationProblemHandler.handleMissingInstantiator() for type %s returned value of type %s", instClass, ClassUtil.classNameOf(instance))); msg = String.format("Cannot construct instance of %s (no Creators, like default construct, exist): %s", ClassUtil.nameOf(instClass), msg); return reportBadDefinition(constructType(instClass), msg);
@Override public JsonDeserializer<?> createContextual(DeserializationContext ctxt, BeanProperty property) throws JsonMappingException { Boolean unwrapSingle = findFormatFeature(ctxt, property, _valueClass, JsonFormat.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY); NullValueProvider nuller = null; Nulls nullStyle = findContentNullStyle(ctxt, property); if (nullStyle == Nulls.SKIP) { nuller = NullsConstantProvider.skipper(); } else if (nullStyle == Nulls.FAIL) { if (property == null) { nuller = NullsFailProvider.constructForRootValue(ctxt.constructType(_valueClass)); } else { nuller = NullsFailProvider.constructForProperty(property); } } if ((unwrapSingle == _unwrapSingle) && (nuller == _nuller)) { return this; } return withResolved(nuller, unwrapSingle); }
return instance; reportBadDefinition(constructType(instClass), String.format( "DeserializationProblemHandler.handleUnexpectedToken() for type %s returned value of type %s", ClassUtil.nameOf(instClass), ClassUtil.classNameOf(instance)));
return instance; reportBadDefinition(constructType(instClass), String.format( "DeserializationProblemHandler.handleInstantiationProblem() for type %s returned value of type %s", instClass, ClassUtil.classNameOf(instance)));
JavaType type = ctxt.constructType(String.class); if (deser == null) { deser = ctxt.findContextualValueDeserializer(type, property);
public void resolve(DeserializationContext ctxt) throws JsonMappingException JavaType obType = ctxt.constructType(Object.class); JavaType stringType = ctxt.constructType(String.class); TypeFactory tf = ctxt.getTypeFactory();
gen = new PropertyBasedObjectIdGenerator(objectIdInfo.getScope()); } else { JavaType type = ctxt.constructType(implClass); idType = ctxt.getTypeFactory().findTypeParameters(type, ObjectIdGenerator.class)[0]; idProp = null;
return NullsFailProvider.constructForRootValue(ctxt.constructType(valueDeser.handledType()));
idGen = new PropertyBasedObjectIdGenerator(objectIdInfo.getScope()); } else { // other types are to be simpler JavaType type = ctxt.constructType(implClass); idType = ctxt.getTypeFactory().findTypeParameters(type, ObjectIdGenerator.class)[0]; idProp = null;
JavaType type = ctxt.constructType(implClass); idType = ctxt.getTypeFactory().findTypeParameters(type, ObjectIdGenerator.class)[0]; idGen = ctxt.objectIdGeneratorInstance(accessor, objectIdInfo);
@Override public JsonDeserializer<Object> createBuilderBasedDeserializer( DeserializationContext ctxt, JavaType valueType, BeanDescription beanDesc, Class<?> builderClass) throws JsonMappingException { // First: need a BeanDescription for builder class JavaType builderType = ctxt.constructType(builderClass); BeanDescription builderDesc = ctxt.getConfig().introspectForBuilder(builderType); return buildBuilderBasedDeserializer(ctxt, valueType, builderDesc); }
@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); }