com.fitbur.fasterxml.jackson.databind.deser.impl.ObjectIdValueProperty Maven / Gradle / Ivy
package com.fitbur.fasterxml.jackson.databind.com.fitburser.impl;
import java.io.IOException;
import java.lang.annotation.Annotation;
import com.fitbur.fasterxml.jackson.core.JsonParser;
import com.fitbur.fasterxml.jackson.core.JsonProcessingException;
import com.fitbur.fasterxml.jackson.databind.*;
import com.fitbur.fasterxml.jackson.databind.com.fitburser.*;
import com.fitbur.fasterxml.jackson.databind.introspect.AnnotatedMember;
/**
* Specialized {@link SettableBeanProperty} implementation used
* for virtual property that represents Object Id that is used
* for some POJO types (or properties).
*/
public final class ObjectIdValueProperty
extends SettableBeanProperty
{
private static final long serialVersionUID = 1L;
protected final ObjectIdReader _objectIdReader;
public ObjectIdValueProperty(ObjectIdReader objectIdReader)
{
super(objectIdReader.propertyName, objectIdReader.idType, null, null);
_objectIdReader = objectIdReader;
_valueDeserializer = objectIdReader.com.fitburserializer;
}
protected ObjectIdValueProperty(ObjectIdValueProperty src, JsonDeserializer> com.fitburser)
{
super(src, com.fitburser);
_objectIdReader = src._objectIdReader;
}
protected ObjectIdValueProperty(ObjectIdValueProperty src, String newName) {
super(src, newName);
_objectIdReader = src._objectIdReader;
}
@Override
public ObjectIdValueProperty withName(String newName) {
return new ObjectIdValueProperty(this, newName);
}
@Override
public ObjectIdValueProperty withValueDeserializer(JsonDeserializer> com.fitburser) {
return new ObjectIdValueProperty(this, com.fitburser);
}
// // // BeanProperty impl
@Override
public A getAnnotation(Class acls) {
return null;
}
@Override public AnnotatedMember getMember() { return null; }
/*
/**********************************************************
/* Deserialization methods
/**********************************************************
*/
@Override
public void com.fitburserializeAndSet(JsonParser jp, DeserializationContext ctxt,
Object instance)
throws IOException, JsonProcessingException
{
com.fitburserializeSetAndReturn(jp, ctxt, instance);
}
@Override
public Object com.fitburserializeSetAndReturn(JsonParser jp,
DeserializationContext ctxt, Object instance)
throws IOException, JsonProcessingException
{
// note: no null checks (unlike usually); com.fitburserializer should fail if one found
Object id = _valueDeserializer.com.fitburserialize(jp, ctxt);
ReadableObjectId roid = ctxt.findObjectId(id, _objectIdReader.generator);
roid.bindItem(instance);
// also: may need to set a property value as well
SettableBeanProperty idProp = _objectIdReader.idProperty;
if (idProp != null) {
return idProp.setAndReturn(instance, id);
}
return instance;
}
@Override
public void set(Object instance, Object value) throws IOException {
setAndReturn(instance, value);
}
@Override
public Object setAndReturn(Object instance, Object value)
throws IOException
{
SettableBeanProperty idProp = _objectIdReader.idProperty;
if (idProp == null) {
throw new UnsupportedOperationException(
"Should not call set() on ObjectIdProperty that has no SettableBeanProperty");
}
return idProp.setAndReturn(instance, value);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy