diff --git a/spring-data-rest-core/src/main/java/org/springframework/data/rest/core/ValidationErrors.java b/spring-data-rest-core/src/main/java/org/springframework/data/rest/core/ValidationErrors.java index 104f49df3..07872fe2c 100644 --- a/spring-data-rest-core/src/main/java/org/springframework/data/rest/core/ValidationErrors.java +++ b/spring-data-rest-core/src/main/java/org/springframework/data/rest/core/ValidationErrors.java @@ -55,9 +55,7 @@ public class ValidationErrors extends AbstractPropertyBindingResult { */ public ValidationErrors(Object source, PersistentEntities entities) { - super(source.getClass().getSimpleName()); - - Assert.notNull(source, "Entity must not be null"); + super(requireNotNull(source, "Entity must not be null").getClass().getSimpleName()); Assert.notNull(entities, "PersistentEntities must not be null"); this.entities = entities; @@ -104,6 +102,10 @@ private Object lookupValueOn(Object value, String segment) { } }; } + private static T requireNotNull(T object, String message) { + Assert.notNull(object, message); + return object; + } @Override public Object getTarget() {