Skip to content

Commit

Permalink
Add support for @ConstructorProperties to jackson-databind (#457)
Browse files Browse the repository at this point in the history
  • Loading branch information
sdeleuze authored Feb 29, 2024
1 parent 9323a66 commit 1eb5cdc
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,12 @@
"condition": {
"typeReachable": "javax.xml.datatype.XMLGregorianCalendar"
}
},
{
"name": "com.fasterxml.jackson.databind.ext.Java7SupportImpl",
"allDeclaredConstructors": true,
"condition": {
"typeReachable": "com.fasterxml.jackson.databind.ext.Java7Support"
}
}
]
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;
}
}

}
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
}
]

0 comments on commit 1eb5cdc

Please sign in to comment.