DATACMNS-867 - Less Optional for auditing subsystem.

Removed Optional<Object> parameters in favor of plain Object and clients that avoid calling methods for absent values in the first place.
This commit is contained in:
Oliver Gierke
2017-03-15 15:26:49 +01:00
parent 5f7d1ae2f2
commit 082c4157d1
13 changed files with 101 additions and 125 deletions

View File

@@ -18,7 +18,6 @@ package org.springframework.data.mapping.context;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import java.util.Arrays;
import java.util.Collections;
import java.util.Optional;
import java.util.function.Function;
@@ -112,11 +111,11 @@ public class MappingContextIsNewStrategyFactory extends IsNewStrategyFactorySupp
* @see org.springframework.data.support.IsNewStrategy#isNew(java.util.Optional)
*/
@Override
public boolean isNew(Optional<? extends Object> entity) {
public boolean isNew(Object entity) {
return entity//
.map(it -> isNew.apply(property.getOwner().getPropertyAccessor(it).getProperty(property)))//
.orElse(false);
Assert.notNull(entity, "Entity must not be null!");
return isNew.apply(property.getOwner().getPropertyAccessor(entity).getProperty(property));
}
}