DATACMNS-1101 - Reinstantiate assertions using Supplier.

This commit is contained in:
Mark Paluch
2017-06-29 13:22:56 +02:00
committed by Oliver Gierke
parent 5015b34a58
commit 4a04251a81

View File

@@ -447,10 +447,8 @@ public class BasicPersistentEntity<T, P extends PersistentProperty<P>> implement
public PersistentPropertyAccessor getPropertyAccessor(Object bean) {
Assert.notNull(bean, "Target bean must not be null!");
if (!getType().isInstance(bean)) { // prevent capturing lambda
throw new IllegalArgumentException(String.format(TYPE_MISMATCH, bean.getClass().getName(), getType().getName()));
}
Assert.isTrue(getType().isInstance(bean),
() -> String.format(TYPE_MISMATCH, bean.getClass().getName(), getType().getName()));
return propertyAccessorFactory.getPropertyAccessor(this, bean);
}
@@ -463,10 +461,8 @@ public class BasicPersistentEntity<T, P extends PersistentProperty<P>> implement
public IdentifierAccessor getIdentifierAccessor(Object bean) {
Assert.notNull(bean, "Target bean must not be null!");
if (!getType().isInstance(bean)) { // prevent capturing lambda
throw new IllegalArgumentException(String.format(TYPE_MISMATCH, bean.getClass().getName(), getType().getName()));
}
Assert.isTrue(getType().isInstance(bean),
() -> String.format(TYPE_MISMATCH, bean.getClass().getName(), getType().getName()));
return hasIdProperty() ? new IdPropertyIdentifierAccessor(this, bean) : new AbsentIdentifierAccessor(bean);
}