@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; } }
/** * Helper method called when given type id cannot be resolved into * concrete deserializer either directly (using given {@link TypeIdResolver}), * or using default type. * Default implementation simply throws a {@link com.fasterxml.jackson.databind.JsonMappingException} to * indicate the problem; sub-classes may choose * * @return If it is possible to resolve type id into a {@link JsonDeserializer} * should return that deserializer; otherwise throw an exception to indicate * the problem. * * @since 2.8 */ protected JavaType _handleUnknownTypeId(DeserializationContext ctxt, String typeId) throws IOException { String extraDesc = _idResolver.getDescForKnownTypeIds(); if (extraDesc == null) { extraDesc = "type ids are not statically known"; } else { extraDesc = "known type ids = " + extraDesc; } if (_property != null) { extraDesc = String.format("%s (for POJO property '%s')", extraDesc, _property.getName()); } return ctxt.handleUnknownTypeId(_baseType, typeId, _idResolver, extraDesc); }
msg = String.format("%s (for POJO property '%s')", msg, _property.getName());
@Override public Object findInjectableValue(Object valueId, DeserializationContext ctxt, BeanProperty forProperty, Object beanInstance) { if (!(valueId instanceof String)) { String type = (valueId == null) ? "[null]" : valueId.getClass().getName(); throw new IllegalArgumentException("Unrecognized inject value id type ("+type+"), expecting String"); } 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; } }
@Override public Object findInjectableValue(Object valueId, DeserializationContext ctxt, BeanProperty forProperty, Object beanInstance) { if (!(valueId instanceof String)) { String type = (valueId == null) ? "[null]" : valueId.getClass().getName(); throw new IllegalArgumentException("Unrecognized inject value id type ("+type+"), expecting String"); } 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; } }
@Override public Object findInjectableValue(Object valueId, DeserializationContext ctxt, BeanProperty forProperty, Object beanInstance) { if (!(valueId instanceof String)) { String type = (valueId == null) ? "[null]" : valueId.getClass().getName(); throw new IllegalArgumentException("Unrecognized inject value id type ("+type+"), expecting String"); } 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; } }
public void putOptionalProperty(BeanProperty property, JsonSchema jsonSchema) { jsonSchema.enrichWithBeanProperty(property); properties.put(property.getName(), jsonSchema); }
public void putOptionalProperty(BeanProperty property, JsonSchema jsonSchema) { jsonSchema.enrichWithBeanProperty(property); properties.put(property.getName(), jsonSchema); }
public JsonSchema putProperty(BeanProperty property, JsonSchema value) { value.setRequired(true); value.enrichWithBeanProperty(property); return properties.put(property.getName(), value); }
public JsonSchema putProperty(BeanProperty property, JsonSchema value) { value.setRequired(true); value.enrichWithBeanProperty(property); return properties.put(property.getName(), value); }
@Override public void property(BeanProperty writer) throws JsonMappingException { Schema schema = schemaForWriter(writer); _fields.add(new Schema.Field(writer.getName(), schema, null, null)); }
private JsonSchema getPropertySchema(BeanProperty writer) { return ((ObjectSchema) getSchema()).getProperties().get(writer.getName()); }
private JsonSchema getPropertySchema(BeanProperty writer) { return ((ObjectSchema) getSchema()).getProperties().get(writer.getName()); }
@Override public void optionalProperty(BeanProperty writer) throws JsonMappingException { addField(writer.getName(), getTSTypeForProperty(writer)); }
@Override public void property(BeanProperty writer) throws JsonMappingException { addField(writer.getName(), getTSTypeForProperty(writer)); }
/** * @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) { String propName = (prop == null) ? "NULL" : ("'"+prop.getName()+"'"); reportMappingException( "Could not find JsonDeserializer for type %s (via property %s)", type, propName); } return (T) deser.deserialize(p, this); }
@Override public void optionalProperty(BeanProperty writer) throws JsonMappingException { Schema schema = schemaForWriter(writer); /* 23-Nov-2012, tatu: Actually let's also assume that primitive type values * are required, as Jackson does not distinguish whether optional has been * defined, or is merely the default setting. */ if (!writer.getType().isPrimitive()) { schema = AvroSchemaHelper.unionWithNull(schema); } _fields.add(new Schema.Field(writer.getName(), schema, null, null)); }
@Override public JsonSerializer<?> createContextual(SerializerProvider prov, BeanProperty property) throws JsonMappingException { if (property != null) { JsonCode dicCodeAnno = property.getAnnotation(JsonCode.class); String codeType = dicCodeAnno == null ? property.getName() : dicCodeAnno.value(); return new CodeSerializer(codeType); } return prov.findNullValueSerializer(property); }
@Override public JsonSerializer<?> createContextual(SerializerProvider prov, BeanProperty property) throws JsonMappingException { if (property != null && Number.class.isAssignableFrom(property.getType().getRawClass())) { CodeNumber dicCodeAnno = property.getAnnotation(CodeNumber.class); String dicCode = dicCodeAnno == null ? property.getName() : dicCodeAnno.value(); return new CodeNumberSerializer(dicCode); } return super.createContextual(prov, property); } }
@Override public JsonSerializer<?> createContextual(SerializerProvider prov, BeanProperty property) throws JsonMappingException { if (property != null && String.class.isAssignableFrom(property.getType().getRawClass())) { CodeString dicCodeAnno = property.getAnnotation(CodeString.class); String dicCode = dicCodeAnno == null ? property.getName() : dicCodeAnno.value(); return new CodeStringSerializer(dicCode); } return prov.findNullValueSerializer(property); }