Skip to content

Commit e4e93a6

Browse files
committed
Use (List|Set).of() where feasible
1 parent c1ec988 commit e4e93a6

10 files changed

+12
-23
lines changed

src/main/java/org/springframework/data/convert/Jsr310Converters.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import java.time.ZoneId;
2929
import java.time.format.DateTimeFormatter;
3030
import java.util.ArrayList;
31-
import java.util.Arrays;
3231
import java.util.Collection;
3332
import java.util.Collections;
3433
import java.util.Date;
@@ -48,7 +47,7 @@
4847
*/
4948
public abstract class Jsr310Converters {
5049

51-
private static final List<Class<?>> CLASSES = Arrays.asList(LocalDateTime.class, LocalDate.class, LocalTime.class,
50+
private static final List<Class<?>> CLASSES = List.of(LocalDateTime.class, LocalDate.class, LocalTime.class,
5251
Instant.class, ZoneId.class, Duration.class, Period.class);
5352

5453
/**

src/main/java/org/springframework/data/repository/query/Parameters.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
import java.lang.reflect.Method;
2121
import java.util.ArrayList;
22-
import java.util.Arrays;
2322
import java.util.Iterator;
2423
import java.util.List;
2524
import java.util.function.Function;
@@ -44,7 +43,7 @@
4443
*/
4544
public abstract class Parameters<S extends Parameters<S, T>, T extends Parameter> implements Streamable<T> {
4645

47-
public static final List<Class<?>> TYPES = Arrays.asList(ScrollPosition.class, Pageable.class, Sort.class,
46+
public static final List<Class<?>> TYPES = List.of(ScrollPosition.class, Pageable.class, Sort.class,
4847
Limit.class);
4948

5049
private static final String PARAM_ON_SPECIAL = format("You must not use @%s on a parameter typed %s or %s",

src/main/java/org/springframework/data/repository/query/ReturnedType.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@
1717

1818
import java.beans.PropertyDescriptor;
1919
import java.util.ArrayList;
20-
import java.util.Arrays;
2120
import java.util.Collections;
22-
import java.util.HashSet;
2321
import java.util.List;
2422
import java.util.Map;
2523
import java.util.Set;
@@ -224,7 +222,7 @@ public List<String> getInputProperties() {
224222
*/
225223
private static final class ReturnedClass extends ReturnedType {
226224

227-
private static final Set<Class<?>> VOID_TYPES = new HashSet<>(Arrays.asList(Void.class, void.class));
225+
private static final Set<Class<?>> VOID_TYPES = Set.of(Void.class, void.class);
228226

229227
private final Class<?> type;
230228
private final boolean isDto;

src/main/java/org/springframework/data/repository/query/SpelQueryContext.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
package org.springframework.data.repository.query;
1717

1818
import java.util.ArrayList;
19-
import java.util.Arrays;
2019
import java.util.Collection;
2120
import java.util.Collections;
2221
import java.util.HashMap;
@@ -301,7 +300,7 @@ Map<String, String> getParameterMap() {
301300
*/
302301
static class QuotationMap {
303302

304-
private static final Collection<Character> QUOTING_CHARACTERS = Arrays.asList('"', '\'');
303+
private static final Collection<Character> QUOTING_CHARACTERS = List.of('"', '\'');
305304

306305
private final List<Range<Integer>> quotedRanges = new ArrayList<>();
307306

src/main/java/org/springframework/data/repository/query/ValueExpressionQueryRewriter.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
package org.springframework.data.repository.query;
1717

1818
import java.util.ArrayList;
19-
import java.util.Arrays;
2019
import java.util.Collection;
2120
import java.util.Collections;
2221
import java.util.HashMap;
@@ -345,7 +344,7 @@ public Map<String, ValueExpression> getParameterMap() {
345344
*/
346345
static class QuotationMap {
347346

348-
private static final Collection<Character> QUOTING_CHARACTERS = Arrays.asList('"', '\'');
347+
private static final Collection<Character> QUOTING_CHARACTERS = List.of('"', '\'');
349348

350349
private final List<Range<Integer>> quotedRanges = new ArrayList<>();
351350

src/main/java/org/springframework/data/repository/query/parser/OrderBySource.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
package org.springframework.data.repository.query.parser;
1717

1818
import java.util.ArrayList;
19-
import java.util.Arrays;
20-
import java.util.HashSet;
2119
import java.util.List;
2220
import java.util.Optional;
2321
import java.util.Set;
@@ -46,7 +44,7 @@ class OrderBySource {
4644
private static final String BLOCK_SPLIT = "(?<=Asc|Desc)(?=\\p{Lu})";
4745
private static final Pattern DIRECTION_SPLIT = Pattern.compile("(.+?)(Asc|Desc)?$");
4846
private static final String INVALID_ORDER_SYNTAX = "Invalid order syntax for part %s";
49-
private static final Set<String> DIRECTION_KEYWORDS = new HashSet<>(Arrays.asList("Asc", "Desc"));
47+
private static final Set<String> DIRECTION_KEYWORDS = Set.of("Asc", "Desc");
5048

5149
private final List<Order> orders;
5250

src/main/java/org/springframework/data/repository/query/parser/Part.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ public static enum Type {
189189

190190
// Need to list them again explicitly as the order is important
191191
// (esp. for IS_NULL, IS_NOT_NULL)
192-
private static final List<Part.Type> ALL = Arrays.asList(IS_NOT_NULL, IS_NULL, BETWEEN, LESS_THAN, LESS_THAN_EQUAL,
192+
private static final List<Part.Type> ALL = List.of(IS_NOT_NULL, IS_NULL, BETWEEN, LESS_THAN, LESS_THAN_EQUAL,
193193
GREATER_THAN, GREATER_THAN_EQUAL, BEFORE, AFTER, NOT_LIKE, LIKE, STARTING_WITH, ENDING_WITH, IS_NOT_EMPTY,
194194
IS_EMPTY, NOT_CONTAINING, CONTAINING, NOT_IN, IN, NEAR, WITHIN, REGEX, EXISTS, TRUE, FALSE,
195195
NEGATING_SIMPLE_PROPERTY, SIMPLE_PROPERTY);

src/main/java/org/springframework/data/util/NullableUtils.java

+2-4
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020
import java.lang.reflect.AnnotatedElement;
2121
import java.lang.reflect.Method;
2222
import java.util.Arrays;
23-
import java.util.Collections;
24-
import java.util.HashSet;
2523
import java.util.List;
2624
import java.util.Map;
2725
import java.util.Optional;
@@ -88,8 +86,8 @@ public abstract class NullableUtils {
8886
private static final Set<Class<?>> NON_NULLABLE_ANNOTATIONS = findClasses("reactor.util.lang.NonNullApi",
8987
NonNullApi.class.getName());
9088

91-
private static final Set<String> WHEN_NULLABLE = new HashSet<>(Arrays.asList("UNKNOWN", "MAYBE", "NEVER"));
92-
private static final Set<String> WHEN_NON_NULLABLE = new HashSet<>(Collections.singletonList("ALWAYS"));
89+
private static final Set<String> WHEN_NULLABLE = Set.of("UNKNOWN", "MAYBE", "NEVER");
90+
private static final Set<String> WHEN_NON_NULLABLE = Set.of("ALWAYS");
9391

9492
private NullableUtils() {}
9593

src/main/java/org/springframework/data/util/TypeCollector.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,9 @@ public class TypeCollector {
4545

4646
private static final Log logger = LogFactory.getLog(TypeCollector.class);
4747

48-
static final Set<String> EXCLUDED_DOMAINS = new HashSet<>(
49-
Arrays.asList("java", "sun.", "jdk.", "reactor.", "kotlinx.", "kotlin.", "org.springframework.core.",
48+
static final Set<String> EXCLUDED_DOMAINS = Set.of("java", "sun.", "jdk.", "reactor.", "kotlinx.", "kotlin.", "org.springframework.core.",
5049
"org.springframework.data.mapping.", "org.springframework.data.repository.", "org.springframework.boot.",
51-
"org.springframework.context.", "org.springframework.beans."));
50+
"org.springframework.context.", "org.springframework.beans.");
5251

5352
private final Predicate<Class<?>> excludedDomainsFilter = type -> {
5453
String packageName = type.getPackageName() + ".";

src/main/java/org/springframework/data/web/ProxyingHandlerMethodArgumentResolver.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
public class ProxyingHandlerMethodArgumentResolver extends ModelAttributeMethodProcessor
4747
implements BeanFactoryAware, BeanClassLoaderAware {
4848

49-
private static final List<String> IGNORED_PACKAGES = Arrays.asList("java", "org.springframework");
49+
private static final List<String> IGNORED_PACKAGES = List.of("java", "org.springframework");
5050

5151
private final SpelAwareProxyProjectionFactory proxyFactory;
5252
private final ObjectFactory<ConversionService> conversionService;

0 commit comments

Comments
 (0)