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

com.talanlabs.componentjackson.ComponentValueInstantiator Maven / Gradle / Ivy

The newest version!
package com.talanlabs.componentjackson;

import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.deser.ValueInstantiator;
import com.talanlabs.component.IComponent;
import com.talanlabs.component.factory.ComponentFactory;

import java.io.IOException;

public class ComponentValueInstantiator extends ValueInstantiator {

    private final Class componentClass;

    private final ValueInstantiator defaultInstantiator;

    public ComponentValueInstantiator(Class componentClass, ValueInstantiator defaultInstantiator) {
        super();

        this.componentClass = componentClass;
        this.defaultInstantiator = defaultInstantiator;
    }

    @Override
    public String getValueTypeDesc() {
        return defaultInstantiator.getValueTypeDesc();
    }

    @Override
    public boolean canCreateUsingDefault() {
        return true;
    }

    @Override
    public Object createUsingDefault(DeserializationContext ctxt) throws IOException {
        return ComponentFactory.getInstance().createInstance(componentClass);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy