DATACMNS-867 - Consistent non-capitalization of Querydsl.

This commit is contained in:
Oliver Gierke
2016-12-20 15:13:48 +01:00
parent 2210f2e8e9
commit 9c6f764131
9 changed files with 25 additions and 28 deletions

View File

@@ -28,7 +28,7 @@ import com.querydsl.core.types.Predicate;
* @author Oliver Gierke
* @author Thomas Darimont
*/
public interface QueryDslPredicateExecutor<T> {
public interface QuerydslPredicateExecutor<T> {
/**
* Returns a single entity matching the given {@link Predicate} or {@literal null} if none was found.

View File

@@ -27,7 +27,7 @@ import org.springframework.util.MultiValueMap;
import com.querydsl.core.types.Predicate;
/**
* {@link RepositoryInvoker} that is aware of a {@link QueryDslPredicateExecutor} and {@link Predicate} to be executed
* {@link RepositoryInvoker} that is aware of a {@link QuerydslPredicateExecutor} and {@link Predicate} to be executed
* for all flavors of {@code findAll(…)}. All other calls are forwarded to the configured delegate.
*
* @author Oliver Gierke
@@ -35,18 +35,18 @@ import com.querydsl.core.types.Predicate;
public class QuerydslRepositoryInvokerAdapter implements RepositoryInvoker {
private final RepositoryInvoker delegate;
private final QueryDslPredicateExecutor<Object> executor;
private final QuerydslPredicateExecutor<Object> executor;
private final Predicate predicate;
/**
* Creates a new {@link QuerydslRepositoryInvokerAdapter} for the given delegate {@link RepositoryInvoker},
* {@link QueryDslPredicateExecutor} and Querydsl {@link Predicate}.
* {@link QuerydslPredicateExecutor} and Querydsl {@link Predicate}.
*
* @param delegate must not be {@literal null}.
* @param executor must not be {@literal null}.
* @param predicate can be {@literal null}.
*/
public QuerydslRepositoryInvokerAdapter(RepositoryInvoker delegate, QueryDslPredicateExecutor<Object> executor,
public QuerydslRepositoryInvokerAdapter(RepositoryInvoker delegate, QuerydslPredicateExecutor<Object> executor,
Predicate predicate) {
Assert.notNull(delegate, "Delegate RepositoryInvoker must not be null!");

View File

@@ -29,10 +29,10 @@ import com.querydsl.core.types.PathType;
* @author Oliver Gierke
*/
@UtilityClass
public class QueryDslUtils {
public class QuerydslUtils {
public static final boolean QUERY_DSL_PRESENT = org.springframework.util.ClassUtils
.isPresent("com.querydsl.core.types.Predicate", QueryDslUtils.class.getClassLoader());
.isPresent("com.querydsl.core.types.Predicate", QuerydslUtils.class.getClassLoader());
/**
* Returns the property path for the given {@link Path}.

View File

@@ -17,6 +17,7 @@ package org.springframework.data.querydsl;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.Optional;
import org.springframework.util.ClassUtils;
import org.springframework.util.ReflectionUtils;
@@ -50,14 +51,12 @@ public enum SimpleEntityPathResolver implements EntityPathResolver {
String pathClassName = getQueryClassName(domainClass);
try {
Class<?> pathClass = ClassUtils.forName(pathClassName, domainClass.getClassLoader());
Field field = getStaticFieldOfType(pathClass);
if (field == null) {
throw new IllegalStateException(String.format(NO_FIELD_FOUND_TEMPLATE, pathClass));
} else {
return (EntityPath<T>) ReflectionUtils.getField(field, null);
}
Class<?> pathClass = ClassUtils.forName(pathClassName, domainClass.getClassLoader());
return getStaticFieldOfType(pathClass)//
.map(it -> (EntityPath<T>) ReflectionUtils.getField(it, null))//
.orElseThrow(() -> new IllegalStateException(String.format(NO_FIELD_FOUND_TEMPLATE, pathClass)));
} catch (ClassNotFoundException e) {
throw new IllegalArgumentException(String.format(NO_CLASS_FOUND_TEMPLATE, pathClassName, domainClass.getName()),
@@ -71,7 +70,7 @@ public enum SimpleEntityPathResolver implements EntityPathResolver {
* @param type
* @return
*/
private Field getStaticFieldOfType(Class<?> type) {
private Optional<Field> getStaticFieldOfType(Class<?> type) {
for (Field field : type.getDeclaredFields()) {
@@ -79,12 +78,12 @@ public enum SimpleEntityPathResolver implements EntityPathResolver {
boolean hasSameType = type.equals(field.getType());
if (isStatic && hasSameType) {
return field;
return Optional.of(field);
}
}
Class<?> superclass = type.getSuperclass();
return Object.class.equals(superclass) ? null : getStaticFieldOfType(superclass);
return Object.class.equals(superclass) ? Optional.empty() : getStaticFieldOfType(superclass);
}
/**

View File

@@ -23,7 +23,7 @@ import java.beans.PropertyDescriptor;
import org.springframework.beans.BeanUtils;
import org.springframework.data.querydsl.EntityPathResolver;
import org.springframework.data.querydsl.QueryDslUtils;
import org.springframework.data.querydsl.QuerydslUtils;
import com.querydsl.core.types.Path;
@@ -82,7 +82,7 @@ class QuerydslPathInformation implements PathInformation {
*/
@Override
public String toDotPath() {
return QueryDslUtils.toDotPath(path);
return QuerydslUtils.toDotPath(path);
}
/*

View File

@@ -31,7 +31,7 @@ import org.springframework.core.env.Environment;
import org.springframework.core.io.ResourceLoader;
import org.springframework.core.io.support.SpringFactoriesLoader;
import org.springframework.core.type.AnnotationMetadata;
import org.springframework.data.querydsl.QueryDslUtils;
import org.springframework.data.querydsl.QuerydslUtils;
import org.springframework.data.web.PageableHandlerMethodArgumentResolver;
import org.springframework.util.ClassUtils;
@@ -146,7 +146,7 @@ public @interface EnableSpringDataWebSupport {
*/
@Override
public String[] selectImports(AnnotationMetadata importingClassMetadata) {
return QueryDslUtils.QUERY_DSL_PRESENT ? new String[] { QuerydslWebConfiguration.class.getName() }
return QuerydslUtils.QUERY_DSL_PRESENT ? new String[] { QuerydslWebConfiguration.class.getName() }
: new String[0];
}
}