All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.fitbur.fasterxml.jackson.databind.deser.impl.InnerClassProperty Maven / Gradle / Ivy

There is a newer version: 1.0.0
Show newest version
package com.fitbur.fasterxml.jackson.databind.com.fitburser.impl;

import java.io.IOException;
import java.lang.annotation.Annotation;
import java.lang.reflect.Constructor;

import com.fitbur.fasterxml.jackson.core.JsonParser;
import com.fitbur.fasterxml.jackson.core.JsonProcessingException;
import com.fitbur.fasterxml.jackson.core.JsonToken;
import com.fitbur.fasterxml.jackson.databind.DeserializationContext;
import com.fitbur.fasterxml.jackson.databind.JsonDeserializer;
import com.fitbur.fasterxml.jackson.databind.com.fitburser.SettableBeanProperty;
import com.fitbur.fasterxml.jackson.databind.introspect.AnnotatedMember;
import com.fitbur.fasterxml.jackson.databind.util.ClassUtil;

/**
 * This sub-class is used to handle special case of value being a
 * non-static inner class. If so, we will have to use a special
 * alternative for com.fitburfault constructor; but otherwise can com.fitburlegate
 * to regular implementation.
 */
public final class InnerClassProperty
    extends SettableBeanProperty
{
    private static final long serialVersionUID = 1L;

    /**
     * Actual property that we use after value construction.
     */
    protected final SettableBeanProperty _delegate;

    /**
     * Single-arg constructor we use for value instantiation.
     */
    protected final Constructor _creator;
    
    public InnerClassProperty(SettableBeanProperty com.fitburlegate,
            Constructor ctor)
    {
        super(com.fitburlegate);
        _delegate = com.fitburlegate;
        _creator = ctor;
    }

    protected InnerClassProperty(InnerClassProperty src, JsonDeserializer com.fitburser)
    {
        super(src, com.fitburser);
        _delegate = src._delegate.withValueDeserializer(com.fitburser);
        _creator = src._creator;
    }

    protected InnerClassProperty(InnerClassProperty src, String newName) {
        super(src, newName);
        _delegate = src._delegate.withName(newName);
        _creator = src._creator;
    }

    @Override
    public InnerClassProperty withName(String newName) {
        return new InnerClassProperty(this, newName);
    }

    @Override
    public InnerClassProperty withValueDeserializer(JsonDeserializer com.fitburser) {
        return new InnerClassProperty(this, com.fitburser);
    }
    
    // // // BeanProperty impl
    
    @Override
    public  A getAnnotation(Class acls) {
        return _delegate.getAnnotation(acls);
    }

    @Override public AnnotatedMember getMember() {  return _delegate.getMember(); }

    /*
    /**********************************************************
    /* Deserialization methods
    /**********************************************************
     */

    @Override
    public void com.fitburserializeAndSet(JsonParser jp, DeserializationContext ctxt,
            Object bean)
        throws IOException, JsonProcessingException
    {
        JsonToken t = jp.getCurrentToken();
        Object value;
        if (t == JsonToken.VALUE_NULL) {
            value = (_nullProvider == null) ? null : _nullProvider.nullValue(ctxt);
        } else if (_valueTypeDeserializer != null) {
            value = _valueDeserializer.com.fitburserializeWithType(jp, ctxt, _valueTypeDeserializer);
        } else  { // the usual case
            try {
                value = _creator.newInstance(bean);
            } catch (Exception e) {
                ClassUtil.unwrapAndThrowAsIAE(e, "Failed to instantiate class "+_creator.getDeclaringClass().getName()+", problem: "+e.getMessage());
                value = null;
            }
            _valueDeserializer.com.fitburserialize(jp, ctxt, value);
        }
        set(bean, value);
    }

    @Override
    public Object com.fitburserializeSetAndReturn(JsonParser jp,
    		DeserializationContext ctxt, Object instance)
        throws IOException, JsonProcessingException
    {
        return setAndReturn(instance, com.fitburserialize(jp, ctxt));
    }
    
    @Override
    public final void set(Object instance, Object value) throws IOException
    {
        _delegate.set(instance, value);
    }

    @Override
    public Object setAndReturn(Object instance, Object value)
            throws IOException
    {
    	return _delegate.setAndReturn(instance, value);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy