DATACMNS-867 - Removed Optional from QuerydslBindingsFactory API.
This commit is contained in:
@@ -20,7 +20,6 @@ import lombok.RequiredArgsConstructor;
|
||||
import lombok.Value;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
@@ -37,7 +36,6 @@ import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.querydsl.core.types.Path;
|
||||
import com.querydsl.core.types.Predicate;
|
||||
|
||||
/**
|
||||
* {@link QuerydslBindings} allows definition of path specific bindings.
|
||||
@@ -478,7 +476,8 @@ public class QuerydslBindings {
|
||||
public <P extends Path<T>> void first(SingleValueBinding<P, T> binding) {
|
||||
|
||||
Assert.notNull(binding, "Binding must not be null!");
|
||||
all((MultiValueBinding<P, T>) (path, value) -> Optionals.next(value.iterator()).flatMap(t -> binding.bind(path, t)));
|
||||
all((MultiValueBinding<P, T>) (path, value) -> Optionals.next(value.iterator())
|
||||
.flatMap(t -> binding.bind(path, t)));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -490,7 +489,7 @@ public class QuerydslBindings {
|
||||
|
||||
Assert.notNull(binding, "Binding must not be null!");
|
||||
|
||||
QuerydslBindings.this.typeSpecs.put(type, PathAndBinding.<T, P>withoutPath().with(binding));
|
||||
QuerydslBindings.this.typeSpecs.put(type, PathAndBinding.<T, P> withoutPath().with(binding));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -84,6 +84,30 @@ public class QuerydslBindingsFactory implements ApplicationContextAware {
|
||||
return entityPathResolver;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the {@link QuerydslBindings} to be used using for the given domain type. A {@link QuerydslBinderCustomizer}
|
||||
* will be auto-detected.
|
||||
*
|
||||
* @param domainType must not be {@literal null}.
|
||||
* @return will never be {@literal null}.
|
||||
*/
|
||||
public QuerydslBindings createBindingsFor(TypeInformation<?> domainType) {
|
||||
return createBindingsFor(domainType, Optional.empty());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the {@link QuerydslBindings} to be used using for the given domain type and a pre-defined
|
||||
* {@link QuerydslBinderCustomizer}.
|
||||
*
|
||||
* @param domainType must not be {@literal null}.
|
||||
* @param customizer the {@link QuerydslBinderCustomizer} to use, must not be {@literal null}.
|
||||
* @return will never be {@literal null}.
|
||||
*/
|
||||
public QuerydslBindings createBindingsFor(TypeInformation<?> domainType,
|
||||
Class<? extends QuerydslBinderCustomizer<?>> customizer) {
|
||||
return createBindingsFor(domainType, Optional.of(customizer));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the {@link QuerydslBindings} to be used using for the given domain type and a pre-defined
|
||||
* {@link QuerydslBinderCustomizer}. If no customizer is given, auto-detection will be applied.
|
||||
@@ -93,7 +117,7 @@ public class QuerydslBindingsFactory implements ApplicationContextAware {
|
||||
* detection for the given domain type will be applied.
|
||||
* @return
|
||||
*/
|
||||
public QuerydslBindings createBindingsFor(TypeInformation<?> domainType,
|
||||
private QuerydslBindings createBindingsFor(TypeInformation<?> domainType,
|
||||
Optional<Class<? extends QuerydslBinderCustomizer<?>>> customizer) {
|
||||
|
||||
Assert.notNull(customizer, "Customizer must not be null!");
|
||||
@@ -141,7 +165,8 @@ public class QuerydslBindingsFactory implements ApplicationContextAware {
|
||||
|
||||
return customizer//
|
||||
.filter(it -> !QuerydslBinderCustomizer.class.equals(it))//
|
||||
.map(this::createQuerydslBinderCustomizer).orElseGet(() -> repositories.flatMap(it -> it.getRepositoryFor(domainType))//
|
||||
.map(this::createQuerydslBinderCustomizer)
|
||||
.orElseGet(() -> repositories.flatMap(it -> it.getRepositoryFor(domainType))//
|
||||
.map(it -> it instanceof QuerydslBinderCustomizer ? (QuerydslBinderCustomizer<EntityPath<?>>) it : null)//
|
||||
.orElse(NoOpCustomizer.INSTANCE));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user