Skip to content

Commit 105682e

Browse files
committed
Second part of #3036 (still need tests)
1 parent b2b6105 commit 105682e

File tree

1 file changed

+40
-2
lines changed

1 file changed

+40
-2
lines changed

src/main/java/com/fasterxml/jackson/databind/cfg/MapperBuilder.java

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import java.text.DateFormat;
66
import java.util.*;
77
import java.util.function.Consumer;
8-
import java.util.function.UnaryOperator;
98

109
import com.fasterxml.jackson.annotation.JsonAutoDetect;
1110
import com.fasterxml.jackson.annotation.JsonInclude;
@@ -25,6 +24,7 @@
2524
import com.fasterxml.jackson.databind.jsontype.TypeResolverBuilder;
2625
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
2726
import com.fasterxml.jackson.databind.ser.*;
27+
import com.fasterxml.jackson.databind.type.LogicalType;
2828
import com.fasterxml.jackson.databind.type.TypeFactory;
2929

3030
/**
@@ -271,7 +271,45 @@ public B withConfigOverride(Class<?> forType,
271271
/* Changing settings, coercion config
272272
/**********************************************************************
273273
*/
274-
274+
275+
/**
276+
* Method for changing coercion config for specific logical types, through
277+
* callback to specific handler.
278+
*
279+
* @since 2.13
280+
*/
281+
public B withCoercionConfig(LogicalType forType,
282+
Consumer<MutableCoercionConfig> handler) {
283+
handler.accept(_mapper.coercionConfigFor(forType));
284+
return _this();
285+
}
286+
287+
/**
288+
* Method for changing coercion config for specific physical type, through
289+
* callback to specific handler.
290+
*
291+
* @since 2.13
292+
*/
293+
public B withCoercionConfig(Class<?> forType,
294+
Consumer<MutableCoercionConfig> handler) {
295+
handler.accept(_mapper.coercionConfigFor(forType));
296+
return _this();
297+
}
298+
299+
/**
300+
* Method for changing target-type-independent coercion configuration defaults.
301+
*
302+
* @since 2.13
303+
*/
304+
public B withCoercionConfigDefaults(Consumer<MutableCoercionConfig> handler) {
305+
handler.accept(_mapper.coercionConfigDefaults());
306+
return _this();
307+
}
308+
309+
// Not possible to support these in 2.x, yet (added in 3.0); would require
310+
// access to "ConfigOverrides" that `ObjectMapper` holds
311+
// public B withAllCoercionConfigs(Consumer<CoercionConfigs> handler)
312+
275313
/*
276314
/**********************************************************************
277315
/* Module registration, discovery, access

0 commit comments

Comments
 (0)