-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for
@ConstructorProperties
to jackson-databind (#457)
- Loading branch information
Showing
3 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
...st/java/com_fasterxml_jackson_core/jackson_databind/JacksonConstructorPropertiesTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright and related rights waived via CC0 | ||
* | ||
* You should have received a copy of the CC0 legalcode along with this | ||
* work. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>. | ||
*/ | ||
package com_fasterxml_jackson_core.jackson_databind; | ||
|
||
import java.beans.ConstructorProperties; | ||
|
||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
class JacksonConstructorPropertiesTest { | ||
|
||
static final ObjectMapper mapper = new ObjectMapper(); | ||
|
||
@Test | ||
void deserializeConstructorProperties() throws JsonProcessingException { | ||
Foo foo = mapper.readValue("{ \"bar\": \"baz\" }", Foo.class); | ||
assertThat(foo.getBar()).isEqualTo("baz"); | ||
} | ||
|
||
static class Foo { | ||
|
||
private String bar; | ||
|
||
@ConstructorProperties("bar") | ||
Foo(String bar) { | ||
this.bar = bar; | ||
} | ||
|
||
String getBar() { | ||
return bar; | ||
} | ||
} | ||
|
||
} |
8 changes: 8 additions & 0 deletions
8
...c/test/resources/META-INF/native-image/jackson-databind-test-metadata/reflect-config.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[ | ||
{ | ||
"name": "com_fasterxml_jackson_core.jackson_databind.JacksonConstructorPropertiesTest$Foo", | ||
"allDeclaredConstructors": true, | ||
"allDeclaredMethods": true, | ||
"allDeclaredFields": true | ||
} | ||
] |