protected KeyDeserializer _handleUnknownKeyDeserializer(DeserializationContext ctxt, JavaType type) throws JsonMappingException { return ctxt.reportBadDefinition(type, "Cannot find a (Map) Key deserializer for type "+type); } }
protected Object deserializeUsingPropertyBasedWithExternalTypeId(JsonParser p, DeserializationContext ctxt) throws IOException { // !!! 04-Mar-2012, TODO: Need to fix -- will not work as is... JavaType t = _targetType; return ctxt.reportBadDefinition(t, String.format( "Deserialization (of %s) with Builder, External type id, @JsonCreator not yet implemented", t)); } }
protected JsonDeserializer<Object> _handleUnknownValueDeserializer(DeserializationContext ctxt, JavaType type) throws JsonMappingException { // Let's try to figure out the reason, to give better error messages Class<?> rawClass = type.getRawClass(); if (!ClassUtil.isConcrete(rawClass)) { return ctxt.reportBadDefinition(type, "Cannot find a Value deserializer for abstract type "+type); } return ctxt.reportBadDefinition(type, "Cannot find a Value deserializer for type "+type); }
/** * Method called to locate deserializer for the passed root-level value. */ protected JsonDeserializer<Object> _findRootDeserializer(DeserializationContext ctxt) throws JsonMappingException { if (_rootDeserializer != null) { return _rootDeserializer; } // Sanity check: must have actual type... JavaType t = _valueType; if (t == null) { ctxt.reportBadDefinition((JavaType) null, "No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(t); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(t); if (deser == null) { // can this happen? ctxt.reportBadDefinition(t, "Cannot find a deserializer for type "+t); } _rootDeserializers.put(t, deser); return deser; }
/** * @since 2.6 */ protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt) throws JsonMappingException { JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE); if (deser == null) { // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE); if (deser == null) { // can this happen? ctxt.reportBadDefinition(JSON_NODE_TYPE, "Cannot find a deserializer for type "+JSON_NODE_TYPE); } _rootDeserializers.put(JSON_NODE_TYPE, deser); } return deser; }
/** * Secondary deserialization method, called in cases where POJO * instance is created as part of deserialization, potentially * after collecting some or all of the properties to set. */ @Override public Object deserialize(JsonParser p, DeserializationContext ctxt, Object value) throws IOException { // 26-Oct-2016, tatu: I cannot see any of making this actually // work correctly, so let's indicate problem right away JavaType valueType = _targetType; // Did they try to give us builder? Class<?> builderRawType = handledType(); Class<?> instRawType = value.getClass(); if (builderRawType.isAssignableFrom(instRawType)) { return ctxt.reportBadDefinition(valueType, String.format( "Deserialization of %s by passing existing Builder (%s) instance not supported", valueType, builderRawType.getName())); } return ctxt.reportBadDefinition(valueType, String.format( "Deserialization of %s by passing existing instance (of %s) not supported", valueType, instRawType.getName())); }
/** * Method called to locate deserializer for the passed root-level value. */ protected JsonDeserializer<Object> _findRootDeserializer(DeserializationContext ctxt, JavaType valueType) throws JsonMappingException { // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? return ctxt.reportBadDefinition(valueType, "Cannot find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; }
public final Object findInjectableValue(Object valueId, BeanProperty forProperty, Object beanInstance) throws JsonMappingException { if (_injectableValues == null) { reportBadDefinition(ClassUtil.classOf(valueId), String.format( "No 'injectableValues' configured, cannot inject value with id [%s]", valueId)); } return _injectableValues.findInjectableValue(valueId, this, forProperty, beanInstance); }
protected void _reportUnwrappedCreatorProperty(DeserializationContext ctxt, BeanDescription beanDesc, AnnotatedParameter param) throws JsonMappingException { ctxt.reportBadDefinition(beanDesc.getType(), String.format( "Cannot define Creator parameter %d as `@JsonUnwrapped`: combination not yet supported", param.getIndex())); }
/** * Method that can be called to locate value to be injected for this * property, if it is configured for this. */ public Object findInjectableValue(DeserializationContext context, Object beanInstance) throws JsonMappingException { if (_injectableValueId == null) { context.reportBadDefinition(ClassUtil.classOf(beanInstance), String.format("Property '%s' (type %s) has no injectable value id configured", getName(), getClass().getName())); } return context.findInjectableValue(_injectableValueId, this, beanInstance); }
/** * @since 2.4 */ @SuppressWarnings("unchecked") public <T> T readValue(JsonParser p, JavaType type) throws IOException { JsonDeserializer<Object> deser = findRootValueDeserializer(type); if (deser == null) { reportBadDefinition(type, "Could not find JsonDeserializer for type "+type); } return (T) deser.deserialize(p, this); }
@Override public Object findInjectableValue(Object valueId, DeserializationContext ctxt, BeanProperty forProperty, Object beanInstance) throws JsonMappingException { if (!(valueId instanceof String)) { ctxt.reportBadDefinition(ClassUtil.classOf(valueId), String.format( "Unrecognized inject value id type (%s), expecting String", ClassUtil.classNameOf(valueId))); } String key = (String) valueId; Object ob = _values.get(key); if (ob == null && !_values.containsKey(key)) { throw new IllegalArgumentException("No injectable id with value '"+key+"' found (for property '"+forProperty.getName()+"')"); } return ob; } }
/** * @since 2.4 */ @SuppressWarnings("unchecked") public <T> T readPropertyValue(JsonParser p, BeanProperty prop, JavaType type) throws IOException { JsonDeserializer<Object> deser = findContextualValueDeserializer(type, prop); if (deser == null) { return reportBadDefinition(type, String.format( "Could not find JsonDeserializer for type %s (via property %s)", type, ClassUtil.nameOf(prop))); } return (T) deser.deserialize(p, this); }
ctxt.reportBadDefinition(getType(), String.format( "Problem deserializing 'setterless' property (\"%s\"): no way to handle typed deser with setterless yet", getName())); ctxt.reportBadDefinition(getType(), String.format( "Problem deserializing 'setterless' property '%s': get method returned null", getName()));
private void _reportMissingSetter(JsonParser p, DeserializationContext ctxt) throws IOException { final String msg = "No fallback setter/field defined for creator property '"+getName()+"'"; // Hmmmh. Should we return quietly (NOP), or error? // Perhaps better to throw an exception, since it's generally an error. if (ctxt != null ) { ctxt.reportBadDefinition(getType(), msg); } else { throw InvalidDefinitionException.from(p, msg, getType()); } } }
@Override // since 2.9 public Object getEmptyValue(DeserializationContext ctxt) throws JsonMappingException { ValueInstantiator vi = getValueInstantiator(); if (vi == null || !vi.canCreateUsingDefault()) { JavaType type = getValueType(); ctxt.reportBadDefinition(type, String.format("Cannot create empty instance of %s, no default Creator", type)); } try { return vi.createUsingDefault(ctxt); } catch (IOException e) { return ClassUtil.throwAsMappingException(ctxt, e); } }
SettableBeanProperty backProp = valueDeser.findBackReference(refName); if (backProp == null) { ctxt.reportBadDefinition(_beanType, String.format( "Cannot handle managed/back reference '%s': no back reference property found from type %s", refName, prop.getType())); boolean isContainer = prop.getType().isContainerType(); if (!backRefType.getRawClass().isAssignableFrom(referredType.getRawClass())) { ctxt.reportBadDefinition(_beanType, String.format( "Cannot handle managed/back reference '%s': back reference type (%s) not compatible with managed type (%s)", refName, backRefType.getRawClass().getName(),
/** * Helper method called to see if given property might be so-called unwrapped * property: these require special handling. */ protected NameTransformer _findPropertyUnwrapper(DeserializationContext ctxt, SettableBeanProperty prop) throws JsonMappingException { AnnotatedMember am = prop.getMember(); if (am != null) { NameTransformer unwrapper = ctxt.getAnnotationIntrospector().findUnwrappingNameTransformer(am); if (unwrapper != null) { // 01-Dec-2016, tatu: As per [databind#265] we cannot yet support passing // of unwrapped values through creator properties, so fail fast if (prop instanceof CreatorProperty) { ctxt.reportBadDefinition(getValueType(), String.format( "Cannot define Creator property \"%s\" as `@JsonUnwrapped`: combination not yet supported", prop.getName())); } return unwrapper; } } return null; }
JavaType delegateType = _valueInstantiator.getDelegateType(ctxt.getConfig()); if (delegateType == null) { ctxt.reportBadDefinition(_containerType, String.format( "Invalid delegate-creator definition for %s: value instantiator (%s) returned true for 'canCreateUsingDelegate()', but null for 'getDelegateType()'", _containerType, JavaType delegateType = _valueInstantiator.getArrayDelegateType(ctxt.getConfig()); if (delegateType == null) { ctxt.reportBadDefinition(_containerType, String.format( "Invalid delegate-creator definition for %s: value instantiator (%s) returned true for 'canCreateUsingArrayDelegate()', but null for 'getArrayDelegateType()'", _containerType,
ctxt.reportBadDefinition(getType(), String.format("Cannot merge polymorphic property '%s'", getName()));