Browse Source

DATACMNS-1101 - Reinstantiate assertions using Supplier.

pull/231/head
Mark Paluch 9 years ago committed by Oliver Gierke
parent
commit
4a04251a81
  1. 12
      src/main/java/org/springframework/data/mapping/model/BasicPersistentEntity.java

12
src/main/java/org/springframework/data/mapping/model/BasicPersistentEntity.java

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

Loading…
Cancel
Save