DATAJPA-1208 - Improved readability.
Using Collections.emptyList() instead of new ArrayList, inlining and early returns. Original pull request: #230.
This commit is contained in:
@@ -53,6 +53,7 @@ import org.springframework.util.Assert;
|
||||
* @author Mark Paluch
|
||||
* @author Christoph Strobl
|
||||
* @author Jens Schauder
|
||||
* @author Сергей Цыпанов
|
||||
*/
|
||||
public abstract class AbstractJpaQuery implements RepositoryQuery {
|
||||
|
||||
@@ -272,7 +273,6 @@ public abstract class AbstractJpaQuery implements RepositoryQuery {
|
||||
}
|
||||
|
||||
Tuple tuple = (Tuple) source;
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
List<TupleElement<?>> elements = tuple.getElements();
|
||||
|
||||
if (elements.size() == 1) {
|
||||
@@ -284,6 +284,7 @@ public abstract class AbstractJpaQuery implements RepositoryQuery {
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
for (TupleElement<?> element : elements) {
|
||||
|
||||
String alias = element.getAlias();
|
||||
|
||||
@@ -52,6 +52,7 @@ import org.springframework.util.StringUtils;
|
||||
* @author Thomas Darimont
|
||||
* @author Christoph Strobl
|
||||
* @author Mark Paluch
|
||||
* @author Сергей Цыпанов
|
||||
*/
|
||||
public class JpaQueryMethod extends QueryMethod {
|
||||
|
||||
@@ -155,14 +156,12 @@ public class JpaQueryMethod extends QueryMethod {
|
||||
*/
|
||||
List<QueryHint> getHints() {
|
||||
|
||||
List<QueryHint> result = new ArrayList<>();
|
||||
|
||||
QueryHints hints = AnnotatedElementUtils.findMergedAnnotation(method, QueryHints.class);
|
||||
if (hints != null) {
|
||||
result.addAll(Arrays.asList(hints.value()));
|
||||
return Arrays.asList(hints.value());
|
||||
}
|
||||
|
||||
return result;
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -43,6 +43,7 @@ import org.springframework.lang.Nullable;
|
||||
* @author Christoph Strobl
|
||||
* @author Jens Schauder
|
||||
* @author Mark Paluch
|
||||
* @author Сергей Цыпанов
|
||||
*/
|
||||
public class PartTreeJpaQuery extends AbstractJpaQuery {
|
||||
|
||||
@@ -156,13 +157,11 @@ public class PartTreeJpaQuery extends AbstractJpaQuery {
|
||||
parameterBinder = getBinder(expressions);
|
||||
}
|
||||
|
||||
TypedQuery<?> jpaQuery = createQuery(criteriaQuery);
|
||||
|
||||
if (parameterBinder == null) {
|
||||
throw new IllegalStateException("ParameterBinder is null!");
|
||||
}
|
||||
|
||||
return restrictMaxResultsIfNecessary(invokeBinding(parameterBinder, jpaQuery, values));
|
||||
return restrictMaxResultsIfNecessary(invokeBinding(parameterBinder, createQuery(criteriaQuery), values));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user