DATACMNS-867 - Adapt codebase after rebase on forward ports.
This commit is contained in:
@@ -22,6 +22,7 @@ import lombok.ToString;
|
||||
|
||||
import java.beans.PropertyDescriptor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.data.mapping.PropertyPath;
|
||||
@@ -118,24 +119,29 @@ class PropertyPathInformation implements PathInformation {
|
||||
*/
|
||||
@Override
|
||||
public Path<?> reifyPath(EntityPathResolver resolver) {
|
||||
return reifyPath(resolver, path, null);
|
||||
return reifyPath(resolver, path, Optional.empty());
|
||||
}
|
||||
|
||||
private static Path<?> reifyPath(EntityPathResolver resolver, PropertyPath path, Path<?> base) {
|
||||
private static Path<?> reifyPath(EntityPathResolver resolver, PropertyPath path, Optional<Path<?>> base) {
|
||||
|
||||
if (base instanceof CollectionPathBase) {
|
||||
return reifyPath(resolver, path, (Path<?>) ((CollectionPathBase<?, ?, ?>) base).any());
|
||||
}
|
||||
Optional<Path<?>> map = base.filter(it -> it instanceof CollectionPathBase)
|
||||
.map(it -> CollectionPathBase.class.cast(it))//
|
||||
.map(CollectionPathBase::any)//
|
||||
.map(it -> Path.class.cast(it))//
|
||||
.map(it -> reifyPath(resolver, path, Optional.of(it)));
|
||||
|
||||
Path<?> entityPath = base != null ? base : resolver.createPath(path.getOwningType().getType());
|
||||
return map.orElseGet(() -> {
|
||||
|
||||
Field field = ReflectionUtils.findField(entityPath.getClass(), path.getSegment());
|
||||
Object value = ReflectionUtils.getField(field, entityPath);
|
||||
Path<?> entityPath = base.orElseGet(() -> resolver.createPath(path.getOwningType().getType()));
|
||||
|
||||
if (path.hasNext()) {
|
||||
return reifyPath(resolver, path.next(), (Path<?>) value);
|
||||
}
|
||||
Field field = ReflectionUtils.findField(entityPath.getClass(), path.getSegment());
|
||||
Object value = ReflectionUtils.getField(field, entityPath);
|
||||
|
||||
return (Path<?>) value;
|
||||
if (path.hasNext()) {
|
||||
return reifyPath(resolver, path.next(), Optional.of((Path<?>) value));
|
||||
}
|
||||
|
||||
return (Path<?>) value;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package org.springframework.data.querydsl.binding;
|
||||
|
||||
import java.beans.PropertyDescriptor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
@@ -40,6 +41,7 @@ import org.springframework.util.StringUtils;
|
||||
import com.querydsl.core.BooleanBuilder;
|
||||
import com.querydsl.core.types.Path;
|
||||
import com.querydsl.core.types.Predicate;
|
||||
import com.querydsl.core.types.dsl.CollectionPathBase;
|
||||
|
||||
/**
|
||||
* Builder assembling {@link Predicate} out of {@link PropertyValues}.
|
||||
@@ -148,7 +150,7 @@ public class QuerydslPredicateBuilder {
|
||||
|
||||
Optional<Path<?>> resolvedPath = bindings.getExistingPath(path);
|
||||
|
||||
return resolvedPath.orElseGet(() -> paths.computeIfAbsent(path, it -> reifyPath(path, Optional.empty())));
|
||||
return resolvedPath.orElseGet(() -> paths.computeIfAbsent(path, it -> it.reifyPath(resolver)));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -192,7 +194,7 @@ public class QuerydslPredicateBuilder {
|
||||
*/
|
||||
private Collection<Object> convertToPropertyPathSpecificType(List<String> source, PathInformation path) {
|
||||
|
||||
Class<?> targetType = path.getLeafProperty().getType();
|
||||
Class<?> targetType = path.getLeafType();
|
||||
|
||||
if (source.isEmpty() || isSingleElementCollectionWithoutText(source)) {
|
||||
return Collections.emptyList();
|
||||
|
||||
@@ -56,6 +56,7 @@ public abstract class RepositoryFactoryBeanSupport<T extends Repository<S, ID>,
|
||||
|
||||
private final Class<? extends T> repositoryInterface;
|
||||
|
||||
private RepositoryFactorySupport factory;
|
||||
private Key queryLookupStrategyKey;
|
||||
private Optional<Class<?>> repositoryBaseClass = Optional.empty();
|
||||
private Optional<Object> customImplementation = Optional.empty();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016 the original author or authors.
|
||||
* Copyright 2016-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -15,9 +15,10 @@
|
||||
*/
|
||||
package org.springframework.data.repository.util;
|
||||
|
||||
import javaslang.collection.LinkedHashMap;
|
||||
import javaslang.collection.LinkedHashSet;
|
||||
import javaslang.collection.Traversable;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
@@ -29,7 +30,6 @@ import org.springframework.core.convert.TypeDescriptor;
|
||||
import org.springframework.core.convert.converter.ConditionalGenericConverter;
|
||||
import org.springframework.core.convert.converter.Converter;
|
||||
import org.springframework.data.repository.util.QueryExecutionConverters.WrapperType;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
/**
|
||||
* Converter implementations to map from and to Javaslang collections.
|
||||
@@ -112,15 +112,15 @@ class JavaslangCollections {
|
||||
public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) {
|
||||
|
||||
if (source instanceof List) {
|
||||
return ReflectionUtils.invokeMethod(LIST_FACTORY_METHOD, null, source);
|
||||
return javaslang.collection.List.ofAll((Iterable<?>) source);
|
||||
}
|
||||
|
||||
if (source instanceof java.util.Set) {
|
||||
return ReflectionUtils.invokeMethod(SET_FACTORY_METHOD, null, source);
|
||||
return LinkedHashSet.ofAll((Iterable<?>) source);
|
||||
}
|
||||
|
||||
if (source instanceof java.util.Map) {
|
||||
return ReflectionUtils.invokeMethod(MAP_FACTORY_METHOD, null, source);
|
||||
return LinkedHashMap.ofAll((java.util.Map<?, ?>) source);
|
||||
}
|
||||
|
||||
return source;
|
||||
@@ -128,9 +128,6 @@ class JavaslangCollections {
|
||||
};
|
||||
|
||||
private static final Set<ConvertiblePair> CONVERTIBLE_PAIRS;
|
||||
private static final Method LIST_FACTORY_METHOD;
|
||||
private static final Method SET_FACTORY_METHOD;
|
||||
private static final Method MAP_FACTORY_METHOD;
|
||||
|
||||
static {
|
||||
|
||||
@@ -139,11 +136,6 @@ class JavaslangCollections {
|
||||
pairs.add(new ConvertiblePair(Map.class, javaslang.collection.Traversable.class));
|
||||
|
||||
CONVERTIBLE_PAIRS = Collections.unmodifiableSet(pairs);
|
||||
|
||||
MAP_FACTORY_METHOD = ReflectionUtils.findMethod(javaslang.collection.LinkedHashMap.class, "ofAll", Map.class);
|
||||
LIST_FACTORY_METHOD = ReflectionUtils.findMethod(javaslang.collection.List.class, "ofAll", Iterable.class);
|
||||
SET_FACTORY_METHOD = ReflectionUtils.findMethod(javaslang.collection.LinkedHashSet.class, "ofAll",
|
||||
Iterable.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,13 +25,13 @@ import scala.Function0;
|
||||
import scala.Option;
|
||||
import scala.runtime.AbstractFunction0;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.core.convert.ConversionService;
|
||||
@@ -60,8 +60,8 @@ import com.google.common.base.Optional;
|
||||
* <li>{@code org.springframework.util.concurrent.ListenableFuture<}</li>
|
||||
* <li>{@code javaslang.control.Option} - as of 1.13</li>
|
||||
* <li>{@code javaslang.collection.Seq}, {@code javaslang.collection.Map}, {@code javaslang.collection.Set} - as of
|
||||
* <li>Reactive wrappers supported by {@link ReactiveWrappers}</li>
|
||||
* 1.13</li>
|
||||
* <li>Reactive wrappers supported by {@link ReactiveWrappers} - as of 2.0</li>
|
||||
* </ul>
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
@@ -482,7 +482,7 @@ public abstract class QueryExecutionConverters {
|
||||
* @param conversionService must not be {@literal null}.
|
||||
*/
|
||||
public NullableWrapperToJavaslangOptionConverter(ConversionService conversionService) {
|
||||
super(conversionService, javaslang.control.Option.none(), getWrapperType());
|
||||
super(conversionService, javaslang.control.Option.none(), javaslang.control.Option.class);
|
||||
}
|
||||
|
||||
public static WrapperType getWrapperType() {
|
||||
@@ -582,17 +582,6 @@ public abstract class QueryExecutionConverters {
|
||||
|
||||
INSTANCE;
|
||||
|
||||
private static final Supplier<Object> NULL_SUPPLIER = new Supplier<Object>() {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see java.util.function.Supplier#get()
|
||||
*/
|
||||
public Object get() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.core.convert.converter.Converter#convert(java.lang.Object)
|
||||
@@ -602,7 +591,7 @@ public abstract class QueryExecutionConverters {
|
||||
public Object convert(Object source) {
|
||||
|
||||
if (source instanceof javaslang.control.Option) {
|
||||
return ((javaslang.control.Option<Object>) source).getOrElse(NULL_SUPPLIER);
|
||||
return ((javaslang.control.Option<Object>) source).getOrElse(() -> null);
|
||||
}
|
||||
|
||||
if (source instanceof Traversable) {
|
||||
|
||||
Reference in New Issue
Block a user