This repository was archived by the owner on Nov 7, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +50
-0
lines changed
main/java/com/fasterxml/jackson/module/paramnames
test/java/com/fasterxml/jackson/module/paramnames Expand file tree Collapse file tree 2 files changed +50
-0
lines changed Original file line number Diff line number Diff line change @@ -36,6 +36,11 @@ public String findImplicitPropertyName(AnnotatedMember m) {
36
36
@ Override
37
37
public JsonCreator .Mode findCreatorBinding (Annotated a ) {
38
38
39
+ JsonCreator ann = a .getAnnotation (JsonCreator .class );
40
+ if (ann != null ) {
41
+ return ann .mode ();
42
+ }
43
+
39
44
return creatorBinding ;
40
45
}
41
46
Original file line number Diff line number Diff line change
1
+ package com .fasterxml .jackson .module .paramnames ;
2
+
3
+ import com .fasterxml .jackson .annotation .JsonCreator ;
4
+ import com .fasterxml .jackson .databind .ObjectMapper ;
5
+ import org .junit .Test ;
6
+
7
+ import java .io .IOException ;
8
+ import java .util .HashMap ;
9
+ import java .util .Map ;
10
+
11
+ import static org .assertj .core .api .BDDAssertions .then ;
12
+
13
+ public class DelegatingCreatorTest {
14
+
15
+ @ Test
16
+ public void shouldNotOverrideJsonCreatorAnnotationWithSpecifiedMode () throws IOException {
17
+
18
+ // given
19
+ ObjectMapper objectMapper = new ObjectMapper ();
20
+ objectMapper .registerModule (new ParameterNamesModule (JsonCreator .Mode .PROPERTIES ));
21
+
22
+ // when
23
+ ClassWithDelegatingCreator actual = objectMapper .readValue ("{\" value\" :\" aValue\" }" , ClassWithDelegatingCreator .class );
24
+
25
+ // then
26
+ Map <String , String > props = new HashMap <>();
27
+ props .put ("value" , "aValue" );
28
+ ClassWithDelegatingCreator expected = new ClassWithDelegatingCreator (props );
29
+ then (actual ).isEqualToComparingFieldByField (expected );
30
+ }
31
+
32
+ static class ClassWithDelegatingCreator {
33
+
34
+ private final String value ;
35
+
36
+ @ JsonCreator (mode = JsonCreator .Mode .DELEGATING )
37
+ ClassWithDelegatingCreator (Map <String , String > props ) {
38
+ this .value = props .get ("value" );
39
+ }
40
+
41
+ String getValue () {
42
+ return value ;
43
+ }
44
+ }
45
+ }
You can’t perform that action at this time.
0 commit comments