com.fasterxml.jackson.databind.deser.impl.ObjectIdReader Java Examples

The following examples show how to use com.fasterxml.jackson.databind.deser.impl.ObjectIdReader. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractDeserializer.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @since 2.9
 */
protected AbstractDeserializer(AbstractDeserializer base,
        ObjectIdReader objectIdReader, Map<String, SettableBeanProperty> props)
{
    _baseType = base._baseType;
    _backRefProperties = base._backRefProperties;
    _acceptString = base._acceptString;
    _acceptBoolean = base._acceptBoolean;
    _acceptInt = base._acceptInt;
    _acceptDouble = base._acceptDouble;

    _objectIdReader = objectIdReader;
    _properties = props;
}
 
Example #2
Source File: DeserializationContext.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @since 2.8
 */
public <T> T reportUnresolvedObjectId(ObjectIdReader oidReader, Object bean)
    throws JsonMappingException
{
    String msg = String.format("No Object Id found for an instance of %s, to assign to property '%s'",
            ClassUtil.classNameOf(bean), oidReader.propertyName);
    return reportInputMismatch(oidReader.idProperty, msg);
}
 
Example #3
Source File: DelegatingDeserializer.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public ObjectIdReader getObjectIdReader() { return _delegatee.getObjectIdReader(); }
 
Example #4
Source File: AbstractDeserializer.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
    public JsonDeserializer<?> createContextual(DeserializationContext ctxt,
            BeanProperty property) throws JsonMappingException
    {
        final AnnotationIntrospector intr = ctxt.getAnnotationIntrospector();
        if (property != null && intr != null) {
            final AnnotatedMember accessor = property.getMember();
            if (accessor != null) {
                ObjectIdInfo objectIdInfo = intr.findObjectIdInfo(accessor);
                if (objectIdInfo != null) { // some code duplication here as well (from BeanDeserializerFactory)
                    JavaType idType;
                    ObjectIdGenerator<?> idGen;
                    SettableBeanProperty idProp = null;
                    ObjectIdResolver resolver = ctxt.objectIdResolverInstance(accessor, objectIdInfo);

                    // 2.1: allow modifications by "id ref" annotations as well:
                    objectIdInfo = intr.findObjectReferenceInfo(accessor, objectIdInfo);
                    Class<?> implClass = objectIdInfo.getGeneratorType();

                    if (implClass == ObjectIdGenerators.PropertyGenerator.class) {
                        PropertyName propName = objectIdInfo.getPropertyName();
                        idProp = (_properties == null) ? null : _properties.get(propName.getSimpleName());
                        if (idProp == null) {
                            ctxt.reportBadDefinition(_baseType, String.format(
                                    "Invalid Object Id definition for %s: cannot find property with name '%s'",
                                    handledType().getName(), propName));
                        }
                        idType = idProp.getType();
                        idGen = new PropertyBasedObjectIdGenerator(objectIdInfo.getScope());
/*
                         ctxt.reportBadDefinition(_baseType, String.format(
/
"Invalid Object Id definition for abstract type %s: cannot use `PropertyGenerator` on polymorphic types using property annotation",
handledType().getName()));
*/
                    } else { // other types simpler
                        resolver = ctxt.objectIdResolverInstance(accessor, objectIdInfo);
                        JavaType type = ctxt.constructType(implClass);
                        idType = ctxt.getTypeFactory().findTypeParameters(type, ObjectIdGenerator.class)[0];
                        idGen = ctxt.objectIdGeneratorInstance(accessor, objectIdInfo);
                    }
                    JsonDeserializer<?> deser = ctxt.findRootValueDeserializer(idType);
                    ObjectIdReader oir = ObjectIdReader.construct(idType, objectIdInfo.getPropertyName(),
                             idGen, deser, idProp, resolver);
                    return new AbstractDeserializer(this, oir, null);
                }
            }
        }
        if (_properties == null) {
            return this;
        }
        // Need to ensure properties are dropped at this point, regardless
        return new AbstractDeserializer(this, _objectIdReader, null);
    }
 
Example #5
Source File: BeanDeserializerBuilder.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public void setObjectIdReader(ObjectIdReader r) {
    _objectIdReader = r;
}
 
Example #6
Source File: BeanDeserializerBuilder.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public ObjectIdReader getObjectIdReader() {
    return _objectIdReader;
}
 
Example #7
Source File: EntityBeanDeserializer.java    From requery with Apache License 2.0 4 votes vote down vote up
EntityBeanDeserializer(BeanDeserializerBase source, ObjectIdReader reader) {
    super(source, reader);
}
 
Example #8
Source File: DataBinderDeserializer.java    From gvnix with GNU General Public License v3.0 4 votes vote down vote up
public DataBinderDeserializer(BeanDeserializerBase source,
        ObjectIdReader objectIdReader) {
    super(source, objectIdReader);
}
 
Example #9
Source File: JsonDeserializer.java    From lams with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Accessor that can be used to check whether this deserializer
 * is expecting to possibly get an Object Identifier value instead of full value
 * serialization, and if so, should be able to resolve it to actual
 * Object instance to return as deserialized value.
 *<p>
 * Default implementation returns null, as support cannot be implemented
 * generically. Some standard deserializers (most notably
 * {@link com.fasterxml.jackson.databind.deser.BeanDeserializer})
 * do implement this feature, and may return reader instance, depending on exact
 * configuration of instance (which is based on type, and referring property).
 * 
 * @return ObjectIdReader used for resolving possible Object Identifier
 *    value, instead of full value serialization, if deserializer can do that;
 *    null if no Object Id is expected.
 * 
 * @since 2.0
 */
public ObjectIdReader getObjectIdReader() { return null; }
 
Example #10
Source File: AbstractDeserializer.java    From lams with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Overridden to return true for those instances that are
 * handling value for which Object Identity handling is enabled
 * (either via value type or referring property).
 */
@Override
public ObjectIdReader getObjectIdReader() {
    return _objectIdReader;
}
 
Example #11
Source File: DataBinderDeserializer.java    From gvnix with GNU General Public License v3.0 2 votes vote down vote up
/**
 * {@inheritDoc}
 * 
 * Uses {@link DataBinderDeserializer}
 */
@Override
public BeanDeserializerBase withObjectIdReader(ObjectIdReader objectIdReader) {
    return new DataBinderDeserializer(this, objectIdReader);
}