DATACMNS-867 - Removed Optional from ResultProcessor.withDynamicProjection(…).

We now expect the PropertyAccessor to either be non-null or the method not being called at all.
This commit is contained in:
Oliver Gierke
2017-02-24 11:58:27 +01:00
parent c84e6c8427
commit a5c4be5f0a
2 changed files with 7 additions and 8 deletions

View File

@@ -23,7 +23,6 @@ import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Stream;
import org.springframework.core.CollectionFactory;
@@ -84,12 +83,14 @@ public class ResultProcessor {
/**
* Returns a new {@link ResultProcessor} with a new projection type obtained from the given {@link ParameterAccessor}.
*
* @param accessor can be {@literal null}.
* @param accessor must not be {@literal null}.
* @return
*/
public ResultProcessor withDynamicProjection(Optional<ParameterAccessor> accessor) {
public ResultProcessor withDynamicProjection(ParameterAccessor accessor) {
return accessor.flatMap(ParameterAccessor::getDynamicProjection)//
Assert.notNull(accessor, "Parameter accessor must not be null!");
return accessor.getDynamicProjection()//
.map(it -> new ResultProcessor(method, factory, it))//
.orElse(this);
}