1 package com.fasterxml.jackson.databind.deser; 2 3 import com.fasterxml.jackson.databind.*; 4 5 /** 6 * Interface for providers of {@link ValueInstantiator} instances. 7 * Implemented when an object wants to provide custom value instantiators, 8 * usually to support custom value types with alternate constructors, or 9 * which need specified post-processing after construction but before 10 * binding data. 11 */ 12 public interface ValueInstantiators 13 { 14 /** 15 * Method called to find the {@link ValueInstantiator} to use for creating 16 * instances of specified type during deserialization. 17 * Note that a default value instantiator is always created first and passed; 18 * if an implementation does not want to modify or replace it, it has to return 19 * passed instance as is (returning null is an error) 20 * 21 * @param config Deserialization configuration in use 22 * @param beanDesc Additional information about POJO type to be instantiated 23 * @param defaultInstantiator Instantiator that will be used if no changes are made; 24 * passed to allow custom instances to use annotation-provided information 25 * (note, however, that earlier {@link ValueInstantiators} may have changed it to 26 * a custom instantiator already) 27 * 28 * @return Instantiator to use; either <code>defaultInstantiator</code> that was passed, 29 * or a custom variant; cannot be null. 30 */ findValueInstantiator(DeserializationConfig config, BeanDescription beanDesc, ValueInstantiator defaultInstantiator)31 public ValueInstantiator findValueInstantiator(DeserializationConfig config, 32 BeanDescription beanDesc, ValueInstantiator defaultInstantiator); 33 34 /** 35 * Basic "NOP" implementation that can be used as the base class for custom implementations. 36 * Safer to extend (instead of implementing {@link ValueInstantiators}) in case later 37 * Jackson versions add new methods in base interface. 38 */ 39 public static class Base implements ValueInstantiators 40 { 41 @Override findValueInstantiator(DeserializationConfig config, BeanDescription beanDesc, ValueInstantiator defaultInstantiator)42 public ValueInstantiator findValueInstantiator(DeserializationConfig config, 43 BeanDescription beanDesc, ValueInstantiator defaultInstantiator) { 44 return defaultInstantiator; 45 } 46 } 47 } 48