DATACMNS-867 - Polishing of Property value type in mapping package.

This commit is contained in:
Oliver Gierke
2017-03-23 13:27:32 +01:00
parent baccb412f0
commit 5f117a00a3
3 changed files with 80 additions and 16 deletions

View File

@@ -207,10 +207,16 @@ public class AbstractPersistentPropertyUnitTests {
private <T> SamplePersistentProperty getProperty(Class<T> type, String name) {
Optional<Field> field = Optional.ofNullable(ReflectionUtils.findField(type, name));
Optional<PropertyDescriptor> descriptor = getPropertyDescriptor(type, name);
Property property = field.map(it -> Property.of(it, getPropertyDescriptor(type, name)))
.orElseGet(() -> Property.of(getPropertyDescriptor(type, name).orElseThrow(
() -> new IllegalArgumentException(String.format("Couldn't find property %s on %s!", name, type)))));
Property property = field
.map(it -> descriptor//
.map(foo -> Property.of(it, foo))//
.orElseGet(() -> Property.of(it)))
.orElseGet(() -> getPropertyDescriptor(type, name)//
.map(it -> Property.of(it))//
.orElseThrow(
() -> new IllegalArgumentException(String.format("Couldn't find property %s on %s!", name, type))));
return new SamplePersistentProperty(property, getEntity(type), typeHolder);
}