DATAREST-1383 - Polishing.
Avoid repeated lookups of PersistentPropertyAccessor in DomainObjectReader for PATCH requests. Formatting.
This commit is contained in:
@@ -217,6 +217,7 @@ public class DomainObjectReader {
|
||||
|
||||
PersistentEntity<?, ?> entity = candidate.get();
|
||||
MappedProperties mappedProperties = MappedProperties.forDeserialization(entity, mapper);
|
||||
PersistentPropertyAccessor accessor = entity.getPropertyAccessor(target);
|
||||
|
||||
for (Iterator<Entry<String, JsonNode>> i = root.fields(); i.hasNext();) {
|
||||
|
||||
@@ -230,7 +231,6 @@ public class DomainObjectReader {
|
||||
}
|
||||
|
||||
PersistentProperty<?> property = mappedProperties.getPersistentProperty(fieldName);
|
||||
PersistentPropertyAccessor accessor = entity.getPropertyAccessor(target);
|
||||
Optional<Object> rawValue = Optional.ofNullable(accessor.getProperty(property));
|
||||
|
||||
if (!rawValue.isPresent() || associationLinks.isLinkableAssociation(property)) {
|
||||
@@ -275,9 +275,7 @@ public class DomainObjectReader {
|
||||
execute(() -> doMerge(objectNode, it, mapper));
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
return mapper.readerForUpdating(target).readValue(root);
|
||||
|
||||
@@ -29,19 +29,7 @@ import lombok.Value;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -174,11 +162,11 @@ public class DomainObjectReaderUnitTests {
|
||||
|
||||
TypeWithGenericMap result = reader.readPut((ObjectNode) node, target, mapper);
|
||||
|
||||
assertThat(result.map.get("a")).isEqualTo((Object) "1");
|
||||
assertThat(result.map.get("a")).isEqualTo("1");
|
||||
|
||||
Object object = result.map.get("b");
|
||||
assertThat(object).isInstanceOf(Map.class);
|
||||
assertThat(((Map<Object, Object>) object).get("c")).isEqualTo((Object) "2");
|
||||
assertThat(((Map<Object, Object>) object).get("c")).isEqualTo("2");
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class) // DATAREST-701
|
||||
@@ -280,7 +268,7 @@ public class DomainObjectReaderUnitTests {
|
||||
|
||||
TypeWithGenericMap result = reader.readPut(payload, map, mapper);
|
||||
|
||||
assertThat(result.map.get("sub1")).isEqualTo((Object) "ok");
|
||||
assertThat(result.map.get("sub1")).isEqualTo("ok");
|
||||
|
||||
List<String> sub2 = as(result.map.get("sub2"), List.class);
|
||||
assertThat(sub2.get(0)).isEqualTo("ok1");
|
||||
@@ -423,8 +411,8 @@ public class DomainObjectReaderUnitTests {
|
||||
assertThat(collection).hasSize(2);
|
||||
|
||||
Iterator<Map<String, Object>> iterator = (Iterator<Map<String, Object>>) collection.iterator();
|
||||
assertThat(iterator.next().get("some")).isEqualTo((Object) "value");
|
||||
assertThat(iterator.next().get("some")).isEqualTo((Object) "otherValue");
|
||||
assertThat(iterator.next().get("some")).isEqualTo("value");
|
||||
assertThat(iterator.next().get("some")).isEqualTo("otherValue");
|
||||
}
|
||||
|
||||
@Test // DATAREST-965
|
||||
|
||||
Reference in New Issue
Block a user