DATAJPA-1208 - Improved readability.

Using Collections.emptyList() instead of new ArrayList, inlining and early returns.

Original pull request: #230.
This commit is contained in:
stsypanov
2017-10-19 22:46:19 +03:00
committed by Jens Schauder
parent 368de326bc
commit 47f6a3e5f5
3 changed files with 7 additions and 8 deletions

View File

@@ -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();

View File

@@ -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();
}
/**

View File

@@ -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));
}
/**