public ManagedReferenceProperty(String refName, SettableBeanProperty forward, SettableBeanProperty backward, Annotations contextAnnotations, boolean isContainer) { super(forward.getName(), forward.getType(), forward._valueTypeDeserializer, contextAnnotations); _referenceName = refName; _managedProperty = forward; _backProperty = backward; _isContainer = isContainer; }
/** * Method that takes in exception of any type, and casts or wraps it * to an IOException or its subclass. */ protected void _throwAsIOE(Exception e, Object value) throws IOException { if (e instanceof IllegalArgumentException) { String actType = (value == null) ? "[NULL]" : value.getClass().getName(); StringBuilder msg = new StringBuilder("Problem deserializing property '").append(getPropertyName()); msg.append("' (expected type: ").append(getType()); msg.append("; actual type: ").append(actType).append(")"); String origMsg = e.getMessage(); if (origMsg != null) { msg.append(", problem: ").append(origMsg); } else { msg.append(" (no error message provided)"); } throw new JsonMappingException(msg.toString(), null, e); } _throwAsIOE(e); }
public PropertyBasedCreator(ValueInstantiator valueInstantiator) { _valueInstantiator = valueInstantiator; _properties = new HashMap<String, SettableBeanProperty>(); // [JACKSON-372]: primitive types need extra care Object[] defValues = null; SettableBeanProperty[] creatorProps = valueInstantiator.getFromObjectArguments(); SettableBeanProperty[] propertiesWithInjectables = null; final int len = creatorProps.length; _propertyCount = len; for (int i = 0; i < len; ++i) { SettableBeanProperty prop = creatorProps[i]; _properties.put(prop.getName(), prop); if (prop.getType().isPrimitive()) { if (defValues == null) { defValues = new Object[len]; } defValues[i] = ClassUtil.defaultValue(prop.getType().getRawClass()); } Object injectableValueId = prop.getInjectableValueId(); if (injectableValueId != null) { if (propertiesWithInjectables == null) { propertiesWithInjectables = new SettableBeanProperty[len]; } propertiesWithInjectables[i] = prop; } } _defaultValues = defValues; _propertiesWithInjectables = propertiesWithInjectables; }
for (SettableBeanProperty prop : _propertyBasedCreator.getCreatorProperties()) { if (!prop.hasValueDeserializer()) { _propertyBasedCreator.assignDeserializer(prop, findDeserializer(config, provider, prop.getType(), prop));
ValueInstantiator vi = bd.getValueInstantiator(); if (!vi.canCreateUsingDefault()) { // no default constructor Class<?> valueClass = prop.getType().getRawClass(); Class<?> enclosing = ClassUtil.getOuterClass(valueClass);
public ManagedReferenceProperty(String refName, SettableBeanProperty forward, SettableBeanProperty backward, Annotations contextAnnotations, boolean isContainer) { super(forward.getName(), forward.getType(), forward._valueTypeDeserializer, contextAnnotations); _referenceName = refName; _managedProperty = forward; _backProperty = backward; _isContainer = isContainer; }
/** * Method that takes in exception of any type, and casts or wraps it * to an IOException or its subclass. */ protected void _throwAsIOE(Exception e, Object value) throws IOException { if (e instanceof IllegalArgumentException) { String actType = (value == null) ? "[NULL]" : value.getClass().getName(); StringBuilder msg = new StringBuilder("Problem deserializing property '").append(getPropertyName()); msg.append("' (expected type: ").append(getType()); msg.append("; actual type: ").append(actType).append(")"); String origMsg = e.getMessage(); if (origMsg != null) { msg.append(", problem: ").append(origMsg); } else { msg.append(" (no error message provided)"); } throw new JsonMappingException(msg.toString(), null, e); } _throwAsIOE(e); }
public PropertyBasedCreator(ValueInstantiator valueInstantiator) { _valueInstantiator = valueInstantiator; _properties = new HashMap<String, SettableBeanProperty>(); // [JACKSON-372]: primitive types need extra care Object[] defValues = null; SettableBeanProperty[] creatorProps = valueInstantiator.getFromObjectArguments(); SettableBeanProperty[] propertiesWithInjectables = null; final int len = creatorProps.length; _propertyCount = len; for (int i = 0; i < len; ++i) { SettableBeanProperty prop = creatorProps[i]; _properties.put(prop.getName(), prop); if (prop.getType().isPrimitive()) { if (defValues == null) { defValues = new Object[len]; } defValues[i] = ClassUtil.defaultValue(prop.getType().getRawClass()); } Object injectableValueId = prop.getInjectableValueId(); if (injectableValueId != null) { if (propertiesWithInjectables == null) { propertiesWithInjectables = new SettableBeanProperty[len]; } propertiesWithInjectables[i] = prop; } } _defaultValues = defValues; _propertiesWithInjectables = propertiesWithInjectables; }
for (SettableBeanProperty prop : _propertyBasedCreator.getCreatorProperties()) { if (!prop.hasValueDeserializer()) { _propertyBasedCreator.assignDeserializer(prop, findDeserializer(config, provider, prop.getType(), prop));
ValueInstantiator vi = bd.getValueInstantiator(); if (!vi.canCreateUsingDefault()) { // no default constructor Class<?> valueClass = prop.getType().getRawClass(); Class<?> enclosing = ClassUtil.getOuterClass(valueClass);
public ManagedReferenceProperty(String refName, SettableBeanProperty forward, SettableBeanProperty backward, Annotations contextAnnotations, boolean isContainer) { super(forward.getName(), forward.getType(), forward._valueTypeDeserializer, contextAnnotations); _referenceName = refName; _managedProperty = forward; _backProperty = backward; _isContainer = isContainer; }
public ManagedReferenceProperty(String refName, SettableBeanProperty forward, SettableBeanProperty backward, Annotations contextAnnotations, boolean isContainer) { super(forward.getName(), forward.getType(), forward._valueTypeDeserializer, contextAnnotations); _referenceName = refName; _managedProperty = forward; _backProperty = backward; _isContainer = isContainer; }
public ManagedReferenceProperty(String refName, SettableBeanProperty forward, SettableBeanProperty backward, Annotations contextAnnotations, boolean isContainer) { super(forward.getName(), forward.getType(), forward._valueTypeDeserializer, contextAnnotations); _referenceName = refName; _managedProperty = forward; _backProperty = backward; _isContainer = isContainer; }
/** * Method called to finalize setup of this deserializer, * after deserializer itself has been registered. This * is needed to handle recursive and transitive dependencies. */ public void resolve(DeserializationConfig config, DeserializerProvider provider) throws JsonMappingException { // just need to worry about property-based one if (_propertyBasedCreator != null) { for (SettableBeanProperty prop : _propertyBasedCreator.properties()) { prop.setValueDeserializer(findDeserializer(config, provider, prop.getType(), prop)); } } }
@Override public BeanDeserializerBuilder updateBuilder(DeserializationConfig config, BasicBeanDescription beanDesc, BeanDeserializerBuilder builder) { Iterator<SettableBeanProperty> beanPropertyIterator = builder.getProperties(); while (beanPropertyIterator.hasNext()) { SettableBeanProperty settableBeanProperty = beanPropertyIterator.next(); Class<?> rawClass = settableBeanProperty.getType().getRawClass(); if (!isBasicType(rawClass)) { SettableBeanProperty newSettableBeanProperty = settableBeanProperty.withValueDeserializer(new PolymorphicDeserializer(rawClass, mapper)); builder.addOrReplaceProperty(newSettableBeanProperty, true); } } return builder; }
/** * Method called to finalize setup of this deserializer, * after deserializer itself has been registered. This * is needed to handle recursive and transitive dependencies. */ public void resolve(DeserializationConfig config, DeserializerProvider provider) throws JsonMappingException { // just need to worry about property-based one if (_propertyBasedCreator != null) { // Need to / should not create separate HashMap<JavaType, JsonDeserializer<Object>> seen = new HashMap<JavaType, JsonDeserializer<Object>>(); for (SettableBeanProperty prop : _propertyBasedCreator.properties()) { prop.setValueDeserializer(findDeserializer(config, provider, prop.getType(), prop.getPropertyName(), seen)); } } }