Is your feature request related to a problem? Please describe.
We could use HTTP PATCH for partial update, currently there is no easy way to know which keys are bound. More background https://github.com/spring-projects/spring-framework/issues/27159
Describe the solution you'd like
Provide an interface like:
public interface BoundKeysAware {
public void setBoundKeys(Set<String> boundKeys);
}
public class User implements BoundKeysAware {
private String username;
private String password = "******";
private Set<String> boundKeys;
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public Set<String> getBoundKeys() {
return boundKeys;
}
public void setBoundKeys(Set<String> boundKeys) {
this.boundKeys = boundKeys;
}
}
@Test
public void test() throws Exception {
ObjectMapper om = new ObjectMapper();
String json = """
{"username": "test", "password": null}
""";
User user = om.readValue(json, User.class);
assertThat(user.getUsername()).isEqualTo("test");
assertThat(user.getPassword()).isNull();
assertThat(user.getBoundKeys()).containsExactly("username", "password");
json = """
{"username": "test"}
""";
user = om.readValue(json, User.class);
assertThat(user.getUsername()).isEqualTo("test");
assertThat(user.getPassword()).isEqualTo("******");
assertThat(user.getBoundKeys()).containsExactly("username");
}
Usage example
No response
Additional context
No response