Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for @ConstructorProperties to jackson-databind #457

Merged
merged 1 commit into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
]
Loading