/** * Method that can be used to 'register' a serializer that caller has resolved * without help of this map. * * @since 2.5 */ public final SerializerAndMapResult addSerializer(Class<?> type, JsonSerializer<Object> serializer) { return new SerializerAndMapResult(serializer, newWith(type, serializer)); }
/** * @since 2.5 */ public final SerializerAndMapResult addSerializer(JavaType type, JsonSerializer<Object> serializer) { return new SerializerAndMapResult(serializer, newWith(type.getRawClass(), serializer)); }
/** * Method called if initial lookup fails, when looking for a key * serializer (possible attached indirectly to a property) * Will both find serializer * and construct new map instance if warranted, and return both. * * @since 2.7 */ public final SerializerAndMapResult findAndAddKeySerializer(Class<?> type, SerializerProvider provider, BeanProperty property) throws JsonMappingException { JsonSerializer<Object> serializer = provider.findKeySerializer(type, property); return new SerializerAndMapResult(serializer, newWith(type, serializer)); }
/** * Method called if initial lookup fails, when looking for a primary * serializer (one that is directly attached to a property). * Will both find serializer * and construct new map instance if warranted, and return both. * * @since 2.3 * * @throws JsonMappingException */ public final SerializerAndMapResult findAndAddPrimarySerializer(Class<?> type, SerializerProvider provider, BeanProperty property) throws JsonMappingException { JsonSerializer<Object> serializer = provider.findPrimaryPropertySerializer(type, property); return new SerializerAndMapResult(serializer, newWith(type, serializer)); }
/** * Method called if initial lookup fails, when looking for a non-primary * serializer (one that is not directly attached to a property). * Will both find serializer * and construct new map instance if warranted, and return both. * * @since 2.3 * * @throws JsonMappingException */ public final SerializerAndMapResult findAndAddSecondarySerializer(Class<?> type, SerializerProvider provider, BeanProperty property) throws JsonMappingException { JsonSerializer<Object> serializer = provider.findValueSerializer(type, property); return new SerializerAndMapResult(serializer, newWith(type, serializer)); }
/** * Method called if initial lookup fails, when looking for a root value * serializer: one that is not directly attached to a property, but needs to * have {@link com.fasterxml.jackson.databind.jsontype.TypeSerializer} wrapped * around it. Will both find the serializer * and construct new map instance if warranted, and return both. * * @since 2.5 * * @throws JsonMappingException */ public final SerializerAndMapResult findAndAddRootValueSerializer(Class<?> type, SerializerProvider provider) throws JsonMappingException { JsonSerializer<Object> serializer = provider.findTypedValueSerializer(type, false, null); return new SerializerAndMapResult(serializer, newWith(type, serializer)); }
protected JsonSerializer<Object> _findAndAddDynamic(PropertySerializerMap map, Class<?> type, SerializerProvider provider) throws JsonMappingException { // 27-Jun-2017, tatu: [databind#1679] Need to avoid StackOverflowError... if (type == Object.class) { // basically just need to call `toString()`, easiest way: JsonSerializer<Object> ser = new Default(Default.TYPE_TO_STRING, type); _dynamicSerializers = map.newWith(type, ser); return ser; } PropertySerializerMap.SerializerAndMapResult result = // null -> for now we won't keep ref or pass BeanProperty; could change map.findAndAddKeySerializer(type, provider, null); // did we get a new map of serializers? If so, start using it if (map != result.map) { _dynamicSerializers = result.map; } return result.serializer; } }
/** * @since 2.5 */ public final SerializerAndMapResult findAndAddRootValueSerializer(JavaType type, SerializerProvider provider) throws JsonMappingException { JsonSerializer<Object> serializer = provider.findTypedValueSerializer(type, false, null); return new SerializerAndMapResult(serializer, newWith(type.getRawClass(), serializer)); }
public final SerializerAndMapResult findAndAddSecondarySerializer(JavaType type, SerializerProvider provider, BeanProperty property) throws JsonMappingException { JsonSerializer<Object> serializer = provider.findValueSerializer(type, property); return new SerializerAndMapResult(serializer, newWith(type.getRawClass(), serializer)); }
public final SerializerAndMapResult findAndAddPrimarySerializer(JavaType type, SerializerProvider provider, BeanProperty property) throws JsonMappingException { JsonSerializer<Object> serializer = provider.findPrimaryPropertySerializer(type, property); return new SerializerAndMapResult(serializer, newWith(type.getRawClass(), serializer)); }
@Override protected JsonSerializer<Object> _findAndAddDynamic(PropertySerializerMap map, Class<?> type, SerializerProvider provider) throws JsonMappingException { JsonSerializer<Object> serializer; if (_nonTrivialBaseType != null) { JavaType subtype = provider.constructSpecializedType(_nonTrivialBaseType, type); serializer = provider.findValueSerializer(subtype, this); } else { serializer = provider.findValueSerializer(type, this); } NameTransformer t = _nameTransformer; if (serializer.isUnwrappingSerializer() // as per [databind#2060], need to also check this, in case someone writes // custom implementation that does not extend standard implementation: && (serializer instanceof UnwrappingBeanSerializer)) { t = NameTransformer.chainedTransformer(t, ((UnwrappingBeanSerializer) serializer)._nameTransformer); } serializer = serializer.unwrappingSerializer(t); _dynamicSerializers = _dynamicSerializers.newWith(type, serializer); return serializer; } }
/** * Helper method that encapsulates logic of retrieving and caching required * serializer. */ private final JsonSerializer<Object> _findCachedSerializer(SerializerProvider provider, Class<?> rawType) throws JsonMappingException { JsonSerializer<Object> ser = _dynamicSerializers.serializerFor(rawType); if (ser == null) { // NOTE: call this instead of `map._findAndAddDynamic(...)` (which in turn calls // `findAndAddSecondarySerializer`) since we may need to apply unwrapper // too, before caching. But calls made are the same if (_referredType.hasGenericTypes()) { // [databind#1673] Must ensure we will resolve all available type information // so as not to miss generic declaration of, say, `List<GenericPojo>`... JavaType fullType = provider.constructSpecializedType(_referredType, rawType); ser = provider.findValueSerializer(fullType, _property); } else { ser = provider.findValueSerializer(rawType, _property); } if (_unwrapper != null) { ser = ser.unwrappingSerializer(_unwrapper); } _dynamicSerializers = _dynamicSerializers.newWith(rawType, ser); } return ser; }
/** * Method that can be used to 'register' a serializer that caller has resolved * without help of this map. * * @since 2.5 */ public final SerializerAndMapResult addSerializer(Class<?> type, JsonSerializer<Object> serializer) { return new SerializerAndMapResult(serializer, newWith(type, serializer)); }
/** * Method called if initial lookup fails; will both find serializer * and construct new map instance if warranted, and return both * @throws JsonMappingException */ public final SerializerAndMapResult findAndAddSerializer(Class<?> type, SerializerProvider provider, BeanProperty property) throws JsonMappingException { JsonSerializer<Object> serializer = provider.findValueSerializer(type, property); return new SerializerAndMapResult(serializer, newWith(type, serializer)); }
/** * Method called if initial lookup fails; will both find serializer * and construct new map instance if warranted, and return both * @throws JsonMappingException */ public final SerializerAndMapResult findAndAddSerializer(Class<?> type, SerializerProvider provider, BeanProperty property) throws JsonMappingException { JsonSerializer<Object> serializer = provider.findValueSerializer(type, property); return new SerializerAndMapResult(serializer, newWith(type, serializer)); }
public final SerializerAndMapResult findAndAddPrimarySerializer(JavaType type, SerializerProvider provider, BeanProperty property) throws JsonMappingException { JsonSerializer<Object> serializer = provider.findPrimaryPropertySerializer(type, property); return new SerializerAndMapResult(serializer, newWith(type.getRawClass(), serializer)); }
/** * @since 2.5 */ public final SerializerAndMapResult findAndAddRootValueSerializer(JavaType type, SerializerProvider provider) throws JsonMappingException { JsonSerializer<Object> serializer = provider.findTypedValueSerializer(type, false, null); return new SerializerAndMapResult(serializer, newWith(type.getRawClass(), serializer)); }
/** * @since 2.5 */ public final SerializerAndMapResult findAndAddRootValueSerializer(JavaType type, SerializerProvider provider) throws JsonMappingException { JsonSerializer<Object> serializer = provider.findTypedValueSerializer(type, false, null); return new SerializerAndMapResult(serializer, newWith(type.getRawClass(), serializer)); }
public final SerializerAndMapResult findAndAddSerializer(JavaType type, SerializerProvider provider, BeanProperty property) throws JsonMappingException { JsonSerializer<Object> serializer = provider.findValueSerializer(type, property); return new SerializerAndMapResult(serializer, newWith(type.getRawClass(), serializer)); }
public final SerializerAndMapResult findAndAddSecondarySerializer(JavaType type, SerializerProvider provider, BeanProperty property) throws JsonMappingException { JsonSerializer<Object> serializer = provider.findValueSerializer(type, property); return new SerializerAndMapResult(serializer, newWith(type.getRawClass(), serializer)); }