Introduce PropertyValueConversionService and specific null-conversion methods.

PropertyValueConverter read and write methods are never called with null values. Instead, PropertyValueConverter now defines readNull and writeNull to encapsulate null conversion. PropertyValueConversionService is a facade that encapsulates these details to simplify converter usage.

Resolves #2577
Closes #2592
This commit is contained in:
Mark Paluch
2022-04-05 11:21:20 +02:00
committed by John Blum
parent d10822e6bd
commit cb5201f9d2
4 changed files with 297 additions and 9 deletions

View File

@@ -226,13 +226,13 @@ public class PropertyValueConverterFactoryUnitTests {
@Nullable
@Override
public String read(@Nullable UUID value, ValueConversionContext context) {
public String read(UUID value, ValueConversionContext context) {
return value.toString();
}
@Nullable
@Override
public UUID write(@Nullable String value, ValueConversionContext context) {
public UUID write(String value, ValueConversionContext context) {
return UUID.fromString(value);
}
}
@@ -248,7 +248,7 @@ public class PropertyValueConverterFactoryUnitTests {
@Nullable
@Override
public String read(@Nullable UUID value, ValueConversionContext<SamplePersistentProperty> context) {
public String read(UUID value, ValueConversionContext<SamplePersistentProperty> context) {
assertThat(someDependency).isNotNull();
return value.toString();
@@ -256,7 +256,7 @@ public class PropertyValueConverterFactoryUnitTests {
@Nullable
@Override
public UUID write(@Nullable String value, ValueConversionContext<SamplePersistentProperty> context) {
public UUID write(String value, ValueConversionContext<SamplePersistentProperty> context) {
assertThat(someDependency).isNotNull();
return UUID.fromString(value);