com.signalfx.shaded.fasterxml.jackson.databind.util.ConstantValueInstantiator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of signalfx-codahale Show documentation
Show all versions of signalfx-codahale Show documentation
Dropwizard Codahale metrics plugin for signalfx
package com.signalfx.shaded.fasterxml.jackson.databind.util;
import java.io.IOException;
import com.signalfx.shaded.fasterxml.jackson.databind.DeserializationContext;
import com.signalfx.shaded.fasterxml.jackson.databind.deser.ValueInstantiator;
/**
* Trivial {@link ValueInstantiator} implementation that will simply return constant
* {@code Object} it is configured with. May be used as-is, or as base class to override
* simplistic behavior further.
*
* @since 2.9.4
*/
public class ConstantValueInstantiator extends ValueInstantiator
{
protected final Object _value;
public ConstantValueInstantiator(Object value) {
_value = value;
}
@Override
public Class> getValueClass() {
return _value.getClass();
}
@Override // yes, since default ctor works
public boolean canInstantiate() { return true; }
@Override
public boolean canCreateUsingDefault() { return true; }
@Override
public Object createUsingDefault(DeserializationContext ctxt) throws IOException {
return _value;
}
}