Skip to content

Commit a936f43

Browse files
committed
Implement #787
1 parent 0abef48 commit a936f43

26 files changed

+194
-181
lines changed

release-notes/VERSION

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ Project: jackson-databind
3636
#769: Fix `JacksonAnnotationIntrospector.findDeserializer` to return `Object` (as per
3737
`AnnotationIntrospector`); similarly for other `findXxx(De)Serializer(...)` methods
3838
#781: Support handling of `@JsonProperty.required` for Creator methods
39+
#787: Add `ObjectMapper setFilterProvider(FilterProvider)` to allow chaining
40+
(suggested by rgoldberg@githin)
3941
- Remove old cglib compatibility tests; cause problems in Eclipse
4042

4143
2.5.4 (not yet released)

src/main/java/com/fasterxml/jackson/databind/ObjectMapper.java

Lines changed: 134 additions & 123 deletions
Large diffs are not rendered by default.

src/test/java/com/fasterxml/jackson/databind/BaseMapTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ protected ObjectReader objectReader() {
136136
}
137137

138138
protected ObjectReader objectReader(Class<?> cls) {
139-
return SHARED_MAPPER.reader(cls);
139+
return SHARED_MAPPER.readerFor(cls);
140140
}
141141

142142
/*

src/test/java/com/fasterxml/jackson/databind/TestJDKSerialization.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public void testObjectWriter() throws IOException
7676

7777
public void testObjectReader() throws IOException
7878
{
79-
ObjectReader origReader = MAPPER.reader(MyPojo.class);
79+
ObjectReader origReader = MAPPER.readerFor(MyPojo.class);
8080
final String JSON = "{\"x\":1,\"y\":2}";
8181
MyPojo p1 = origReader.readValue(JSON);
8282
assertEquals(2, p1.y);

src/test/java/com/fasterxml/jackson/databind/TestRootName.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public void testRootViaWriterAndReader() throws Exception
4747
ObjectMapper mapper = rootMapper();
4848
String json = mapper.writer().writeValueAsString(new Bean());
4949
assertEquals("{\"rudy\":{\"a\":3}}", json);
50-
Bean bean = mapper.reader(Bean.class).readValue(json);
50+
Bean bean = mapper.readerFor(Bean.class).readValue(json);
5151
assertNotNull(bean);
5252
}
5353

@@ -67,14 +67,14 @@ public void testReconfiguringOfWrapping() throws Exception
6767
Bean result = mapper.readValue(jsonUnwrapped, Bean.class);
6868
assertNotNull(result);
6969
try { // must not have extra wrapping
70-
result = mapper.reader(Bean.class).with(DeserializationFeature.UNWRAP_ROOT_VALUE)
70+
result = mapper.readerFor(Bean.class).with(DeserializationFeature.UNWRAP_ROOT_VALUE)
7171
.readValue(jsonUnwrapped);
7272
fail("Should have failed");
7373
} catch (JsonMappingException e) {
7474
verifyException(e, "Root name 'a'");
7575
}
7676
// except wrapping may be expected:
77-
result = mapper.reader(Bean.class).with(DeserializationFeature.UNWRAP_ROOT_VALUE)
77+
result = mapper.readerFor(Bean.class).with(DeserializationFeature.UNWRAP_ROOT_VALUE)
7878
.readValue(jsonWrapped);
7979
assertNotNull(result);
8080
}
@@ -87,7 +87,7 @@ public void testRootUsingExplicitConfig() throws Exception
8787
String json = writer.writeValueAsString(new Bean());
8888
assertEquals("{\"wrapper\":{\"a\":3}}", json);
8989

90-
ObjectReader reader = mapper.reader(Bean.class).withRootName("wrapper");
90+
ObjectReader reader = mapper.readerFor(Bean.class).withRootName("wrapper");
9191
Bean bean = reader.readValue(json);
9292
assertNotNull(bean);
9393

@@ -102,16 +102,16 @@ public void testRootUsingExplicitConfig() throws Exception
102102
json = wrapping.writer().withoutRootName().writeValueAsString(new Bean());
103103
assertEquals("{\"a\":3}", json);
104104

105-
bean = wrapping.reader(Bean.class).withRootName("").readValue(json);
105+
bean = wrapping.readerFor(Bean.class).withRootName("").readValue(json);
106106
assertNotNull(bean);
107107
assertEquals(3, bean.a);
108108

109-
bean = wrapping.reader(Bean.class).withoutRootName().readValue("{\"a\":4}");
109+
bean = wrapping.readerFor(Bean.class).withoutRootName().readValue("{\"a\":4}");
110110
assertNotNull(bean);
111111
assertEquals(4, bean.a);
112112

113113
// and back to defaults
114-
bean = wrapping.reader(Bean.class).readValue("{\"rudy\":{\"a\":7}}");
114+
bean = wrapping.readerFor(Bean.class).readValue("{\"rudy\":{\"a\":7}}");
115115
assertNotNull(bean);
116116
assertEquals(7, bean.a);
117117
}

src/test/java/com/fasterxml/jackson/databind/contextual/TestContextAttributeWithDeser.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@ static class TestPOJO
5050
public void testSimplePerCall() throws Exception
5151
{
5252
final String INPUT = aposToQuotes("[{'value':'a'},{'value':'b'}]");
53-
TestPOJO[] pojos = MAPPER.reader(TestPOJO[].class).readValue(INPUT);
53+
TestPOJO[] pojos = MAPPER.readerFor(TestPOJO[].class).readValue(INPUT);
5454
assertEquals(2, pojos.length);
5555
assertEquals("a/0", pojos[0].value);
5656
assertEquals("b/1", pojos[1].value);
5757

5858
// and verify that state does not linger
59-
TestPOJO[] pojos2 = MAPPER.reader(TestPOJO[].class).readValue(INPUT);
59+
TestPOJO[] pojos2 = MAPPER.readerFor(TestPOJO[].class).readValue(INPUT);
6060
assertEquals(2, pojos2.length);
6161
assertEquals("a/0", pojos2[0].value);
6262
assertEquals("b/1", pojos2[1].value);
@@ -65,13 +65,13 @@ public void testSimplePerCall() throws Exception
6565
public void testSimpleDefaults() throws Exception
6666
{
6767
final String INPUT = aposToQuotes("{'value':'x'}");
68-
TestPOJO pojo = MAPPER.reader(TestPOJO.class)
68+
TestPOJO pojo = MAPPER.readerFor(TestPOJO.class)
6969
.withAttribute(KEY, Integer.valueOf(3))
7070
.readValue(INPUT);
7171
assertEquals("x/3", pojo.value);
7272

7373
// as above, should not carry on state
74-
TestPOJO pojo2 = MAPPER.reader(TestPOJO.class)
74+
TestPOJO pojo2 = MAPPER.readerFor(TestPOJO.class)
7575
.withAttribute(KEY, Integer.valueOf(5))
7676
.readValue(INPUT);
7777
assertEquals("x/5", pojo2.value);
@@ -80,7 +80,7 @@ public void testSimpleDefaults() throws Exception
8080
public void testHierarchic() throws Exception
8181
{
8282
final String INPUT = aposToQuotes("[{'value':'x'},{'value':'y'}]");
83-
ObjectReader r = MAPPER.reader(TestPOJO[].class).withAttribute(KEY, Integer.valueOf(2));
83+
ObjectReader r = MAPPER.readerFor(TestPOJO[].class).withAttribute(KEY, Integer.valueOf(2));
8484
TestPOJO[] pojos = r.readValue(INPUT);
8585
assertEquals(2, pojos.length);
8686
assertEquals("x/2", pojos[0].value);

src/test/java/com/fasterxml/jackson/databind/creators/RequiredCreatorTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public FascistPoint(@JsonProperty(value="x", required=true) int x,
1818
}
1919
}
2020

21-
private final ObjectReader POINT_READER = objectMapper().reader(FascistPoint.class);
21+
private final ObjectReader POINT_READER = objectMapper().readerFor(FascistPoint.class);
2222

2323
public void testRequiredAnnotatedParam() throws Exception
2424
{

src/test/java/com/fasterxml/jackson/databind/creators/TestPolymorphicCreators.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ public void testManualPolymorphicCatWithReorder() throws Exception
130130
public void testManualPolymorphicWithNumbered() throws Exception
131131
{
132132
final ObjectWriter w = MAPPER.writerFor(AbstractRoot.class);
133-
final ObjectReader r = MAPPER.reader(AbstractRoot.class);
133+
final ObjectReader r = MAPPER.readerFor(AbstractRoot.class);
134134

135135
AbstractRoot input = AbstractRoot.make(1, "oh hai!");
136136
String json = w.writeValueAsString(input);

src/test/java/com/fasterxml/jackson/databind/creators/TestValueUpdate.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ void setB(String b) {
4040
public void testValueUpdateWithCreator() throws Exception
4141
{
4242
Bean bean = new Bean("abc", "def");
43-
new ObjectMapper().reader(Bean.class).withValueToUpdate(bean).readValue("{\"a\":\"ghi\",\"b\":\"jkl\"}");
43+
new ObjectMapper().readerFor(Bean.class).withValueToUpdate(bean).readValue("{\"a\":\"ghi\",\"b\":\"jkl\"}");
4444
assertEquals("ghi", bean.getA());
4545
assertEquals("jkl", bean.getB());
4646
}

src/test/java/com/fasterxml/jackson/databind/deser/TestAnnotationIgnore.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public void testSimpleIgnore() throws Exception
5757

5858
public void testFailOnIgnore() throws Exception
5959
{
60-
ObjectReader r = MAPPER.reader(NoYOrZ.class);
60+
ObjectReader r = MAPPER.readerFor(NoYOrZ.class);
6161

6262
// First, fine to get "x":
6363
NoYOrZ result = r.readValue(aposToQuotes("{'x':3}"));

0 commit comments

Comments
 (0)