DATACMNS-1755 - Use method references in favor of lambdas.

Simplify several lambda expressions in the codebase by using
method references.

Original pull request: #448.
This commit is contained in:
Phillip Webb
2020-05-21 15:40:59 -07:00
committed by Mark Paluch
parent cb8443e299
commit b42cdb6568
10 changed files with 18 additions and 17 deletions

View File

@@ -198,9 +198,9 @@ public class PersistentEntities implements Streamable<PersistentEntity<?, ? exte
Collection<PersistentEntity<?, ?>> entities = contexts.stream() //
.flatMap(it -> it.getPersistentEntities().stream()) //
.map(it -> it.getIdProperty()) //
.map(PersistentEntity::getIdProperty) //
.filter(it -> it != null && type.equals(it.getTypeInformation().getActualType())) //
.map(it -> it.getOwner()) //
.map(PersistentProperty::getOwner) //
.collect(Collectors.toList());
if (entities.size() > 1) {

View File

@@ -47,7 +47,7 @@ import org.springframework.util.StringUtils;
*/
class PersistentPropertyPathFactory<E extends PersistentEntity<?, P>, P extends PersistentProperty<P>> {
private static final Predicate<PersistentProperty<? extends PersistentProperty<?>>> IS_ENTITY = it -> it.isEntity();
private static final Predicate<PersistentProperty<? extends PersistentProperty<?>>> IS_ENTITY = PersistentProperty::isEntity;
private final Map<TypeAndPath, PersistentPropertyPath<P>> propertyPaths = new ConcurrentReferenceHashMap<>();
private final MappingContext<E, P> context;

View File

@@ -310,7 +310,7 @@ public abstract class AnnotationBasedPersistentProperty<P extends PersistentProp
}
String builder = annotationCache.values().stream() //
.flatMap(it -> Optionals.toStream(it)) //
.flatMap(Optionals::toStream) //
.map(Object::toString) //
.collect(Collectors.joining(" "));

View File

@@ -92,7 +92,7 @@ public class MappingInstantiationException extends RuntimeException {
}
return String.format(TEXT_TEMPLATE, it.getType().getName(),
constructor.map(c -> toString(c)).orElse("NO_CONSTRUCTOR"), //
constructor.map(MappingInstantiationException::toString).orElse("NO_CONSTRUCTOR"), //
String.join(",", toStringArgs));
}).orElse(defaultMessage);