diff --git a/src/main/java/org/springframework/data/jpa/convert/QueryByExamplePredicateBuilder.java b/src/main/java/org/springframework/data/jpa/convert/QueryByExamplePredicateBuilder.java index 32bfd5d28..6a2a9ddb1 100644 --- a/src/main/java/org/springframework/data/jpa/convert/QueryByExamplePredicateBuilder.java +++ b/src/main/java/org/springframework/data/jpa/convert/QueryByExamplePredicateBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 the original author or authors. + * Copyright 2016-2018 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. @@ -18,6 +18,7 @@ package org.springframework.data.jpa.convert; import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; +import java.util.EnumSet; import java.util.List; import java.util.Set; @@ -91,7 +92,7 @@ public class QueryByExamplePredicateBuilder { return predicates.iterator().next(); } - Predicate[] array = predicates.toArray(new Predicate[predicates.size()]); + Predicate[] array = predicates.toArray(new Predicate[0]); return matcher.isAllMatching() ? cb.and(array) : cb.or(array); } diff --git a/src/main/java/org/springframework/data/jpa/domain/JpaSort.java b/src/main/java/org/springframework/data/jpa/domain/JpaSort.java index 54cd326b7..3db4ffb94 100644 --- a/src/main/java/org/springframework/data/jpa/domain/JpaSort.java +++ b/src/main/java/org/springframework/data/jpa/domain/JpaSort.java @@ -187,7 +187,7 @@ public class JpaSort extends Sort { public static , T, S> Path path(A attribute) { Assert.notNull(attribute, "Attribute must not be null!"); - return new Path(Arrays.asList(attribute)); + return new Path(Collections.singletonList(attribute)); } /** @@ -200,7 +200,7 @@ public class JpaSort extends Sort { public static

, T, S> Path path(P attribute) { Assert.notNull(attribute, "Attribute must not be null!"); - return new Path(Arrays.asList(attribute)); + return new Path(Collections.singletonList(attribute)); } /** @@ -240,7 +240,7 @@ public class JpaSort extends Sort { Assert.notEmpty(properties, "Properties must not be empty!"); - List orders = new ArrayList(); + List orders = new ArrayList(properties.size()); for (String property : properties) { orders.add(new JpaOrder(direction, property)); @@ -384,7 +384,7 @@ public class JpaSort extends Sort { Assert.notEmpty(properties, "Properties must not be empty!"); Assert.noNullElements(properties, "Properties must not contain null values!"); - List orders = new ArrayList(); + List orders = new ArrayList(properties.length); for (String property : properties) { orders.add(new JpaOrder(getDirection(), property, getNullHandling(), isIgnoreCase(), this.unsafe)); diff --git a/src/main/java/org/springframework/data/jpa/repository/support/Querydsl.java b/src/main/java/org/springframework/data/jpa/repository/support/Querydsl.java index 9ad51732b..59370bd86 100644 --- a/src/main/java/org/springframework/data/jpa/repository/support/Querydsl.java +++ b/src/main/java/org/springframework/data/jpa/repository/support/Querydsl.java @@ -148,7 +148,7 @@ public class Querydsl { private JPQLQuery addOrderByFrom(QSort qsort, JPQLQuery query) { List> orderSpecifiers = qsort.getOrderSpecifiers(); - return query.orderBy(orderSpecifiers.toArray(new OrderSpecifier[orderSpecifiers.size()])); + return query.orderBy(orderSpecifiers.toArray(new OrderSpecifier[0])); } /** diff --git a/src/main/java/org/springframework/data/jpa/repository/support/SimpleJpaRepository.java b/src/main/java/org/springframework/data/jpa/repository/support/SimpleJpaRepository.java index 25d790ce5..120864abb 100644 --- a/src/main/java/org/springframework/data/jpa/repository/support/SimpleJpaRepository.java +++ b/src/main/java/org/springframework/data/jpa/repository/support/SimpleJpaRepository.java @@ -751,12 +751,12 @@ public class SimpleJpaRepository * @param query must not be {@literal null}. * @return */ - private static Long executeCountQuery(TypedQuery query) { + private static long executeCountQuery(TypedQuery query) { Assert.notNull(query, "TypedQuery must not be null!"); List totals = query.getResultList(); - Long total = 0L; + long total = 0L; for (Long element : totals) { total += element == null ? 0 : element; diff --git a/src/main/java/org/springframework/data/jpa/util/BeanDefinitionUtils.java b/src/main/java/org/springframework/data/jpa/util/BeanDefinitionUtils.java index c54a8e499..c9c557f27 100644 --- a/src/main/java/org/springframework/data/jpa/util/BeanDefinitionUtils.java +++ b/src/main/java/org/springframework/data/jpa/util/BeanDefinitionUtils.java @@ -71,8 +71,8 @@ public class BeanDefinitionUtils { */ public static Iterable getEntityManagerFactoryBeanNames(ListableBeanFactory beanFactory) { - Set names = new HashSet(); - names.addAll(asList(beanNamesForTypeIncludingAncestors(beanFactory, EntityManagerFactory.class, true, false))); + String[] beanNames = beanNamesForTypeIncludingAncestors(beanFactory, EntityManagerFactory.class, true, false); + Set names = new HashSet(asList(beanNames)); for (String factoryBeanName : beanNamesForTypeIncludingAncestors(beanFactory, AbstractEntityManagerFactoryBean.class, true, false)) {