@Override public SettableBeanProperty withValueDeserializer(JsonDeserializer<?> deser) { if (_valueDeserializer == deser) { return this; } return new CreatorProperty(this, deser, _nullProvider); }
@Override public void deserializeAndSet(JsonParser p, DeserializationContext ctxt, Object instance) throws IOException { _verifySetter(); _fallbackSetter.set(instance, deserialize(p, ctxt)); }
/** * Method to find value to inject, and inject it to this property. */ public void inject(DeserializationContext context, Object beanInstance) throws IOException { set(beanInstance, findInjectableValue(context, beanInstance)); }
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 public void deserializeAndSet(JsonParser jp, DeserializationContext ctxt, Object instance) throws IOException, JsonProcessingException { set(instance, deserialize(jp, ctxt)); }
@Override public String toString() { return "[creator property, name '"+getName()+"'; inject id '"+_injectableValueId+"']"; }
@Override public Object deserializeSetAndReturn(JsonParser jp, DeserializationContext ctxt, Object instance) throws IOException, JsonProcessingException { return setAndReturn(instance, deserialize(jp, ctxt)); }
public void addPropertyCreator(AnnotatedWithParams creator, CreatorProperty[] properties) { _propertyBasedCreator = verifyNonDup(creator, _propertyBasedCreator, "property-based"); // [JACKSON-470] Better ensure we have no duplicate names either... if (properties.length > 1) { HashMap<String,Integer> names = new HashMap<String,Integer>(); for (int i = 0, len = properties.length; i < len; ++i) { String name = properties[i].getName(); /* [Issue-13]: Need to consider Injectables, which may not have * a name at all, and need to be skipped */ if (name.length() == 0 && properties[i].getInjectableValueId() != null) { continue; } Integer old = names.put(name, Integer.valueOf(i)); if (old != null) { throw new IllegalArgumentException("Duplicate creator property \""+name+"\" (index "+old+" vs "+i+")"); } } } _propertyBasedArgs = properties; }
typeDeser = findTypeDeserializer(config, type); CreatorProperty prop = new CreatorProperty(name, type, typeDeser, beanDesc.getClassAnnotations(), param, index, injectableValueId); if (deser != null) { prop = prop.withValueDeserializer(deser);
cprop.setFallbackSetter(prop); views = beanDesc.findDefaultViews(); cprop.setViews(views); builder.addCreatorProperty(cprop); continue;
args[i] = delegate; } else { // nope, injectable: args[i] = ctxt.findInjectableValue(prop.getInjectableValueId(), prop, null);
cprop.setFallbackSetter(prop);
@Override public void deserializeAndSet(JsonParser jp, DeserializationContext ctxt, Object instance) throws IOException, JsonProcessingException { set(instance, deserialize(jp, ctxt)); }
/** * 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); }
@Override public Object deserializeSetAndReturn(JsonParser jp, DeserializationContext ctxt, Object instance) throws IOException, JsonProcessingException { return setAndReturn(instance, deserialize(jp, ctxt)); }
public void addPropertyCreator(AnnotatedWithParams creator, CreatorProperty[] properties) { _propertyBasedCreator = verifyNonDup(creator, _propertyBasedCreator, "property-based"); // [JACKSON-470] Better ensure we have no duplicate names either... if (properties.length > 1) { HashMap<String,Integer> names = new HashMap<String,Integer>(); for (int i = 0, len = properties.length; i < len; ++i) { String name = properties[i].getName(); /* [Issue-13]: Need to consider Injectables, which may not have * a name at all, and need to be skipped */ if (name.length() == 0 && properties[i].getInjectableValueId() != null) { continue; } Integer old = names.put(name, Integer.valueOf(i)); if (old != null) { throw new IllegalArgumentException("Duplicate creator property \""+name+"\" (index "+old+" vs "+i+")"); } } } _propertyBasedArgs = properties; }
typeDeser = findTypeDeserializer(config, type); CreatorProperty prop = new CreatorProperty(name, type, typeDeser, beanDesc.getClassAnnotations(), param, index, injectableValueId); if (deser != null) { prop = prop.withValueDeserializer(deser);
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()); } } }
cprop.setFallbackSetter(prop); views = beanDesc.findDefaultViews(); cprop.setViews(views); builder.addCreatorProperty(cprop); continue;
args[i] = delegate; } else { // nope, injectable: args[i] = ctxt.findInjectableValue(prop.getInjectableValueId(), prop, null);