Add (de)serializerByType() and mixIn() to Jackson2ObjectMapperBuilder

Issue: SPR-12313
This commit is contained in:
Sebastien Deleuze
2014-10-08 10:50:31 +02:00
parent 25bb58a1e8
commit f518ad9009
2 changed files with 96 additions and 23 deletions

View File

@@ -172,6 +172,18 @@ public class Jackson2ObjectMapperBuilder {
return this;
}
/**
* Configure a custom serializer for the given type.
* @see #serializers(JsonSerializer...)
* @since 4.1.2
*/
public Jackson2ObjectMapperBuilder serializerByType(Class<?> type, JsonSerializer<?> serializer) {
if (serializers != null) {
this.serializers.put(type, serializer);
}
return this;
}
/**
* Configure custom serializers for the given types.
* @see #serializers(JsonSerializer...)
@@ -183,6 +195,17 @@ public class Jackson2ObjectMapperBuilder {
return this;
}
/**
* Configure a custom deserializer for the given type.
* @since 4.1.2
*/
public Jackson2ObjectMapperBuilder deserializerByType(Class<?> type, JsonDeserializer<?> deserializer) {
if (deserializers != null) {
this.deserializers.put(type, deserializer);
}
return this;
}
/**
* Configure custom deserializers for the given types.
*/
@@ -193,6 +216,21 @@ public class Jackson2ObjectMapperBuilder {
return this;
}
/**
* Add mix-in annotations to use for augmenting specified class or interface.
* @param target class (or interface) whose annotations to effectively override
* @param mixinSource class (or interface) whose annotations are to be "added"
* to target's annotations as value
* @since 4.1.2
* @see com.fasterxml.jackson.databind.ObjectMapper#addMixInAnnotations(Class, Class)
*/
public Jackson2ObjectMapperBuilder mixIn(Class<?> target, Class<?> mixinSource) {
if (mixIns != null) {
this.mixIns.put(target, mixinSource);
}
return this;
}
/**
* Add mix-in annotations to use for augmenting specified class or interface.
* @param mixIns Map of entries with target classes (or interface) whose annotations