Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use (List|Set).of() where feasible #3231

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
Expand All @@ -48,7 +47,7 @@
*/
public abstract class Jsr310Converters {

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

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.function.Function;
Expand All @@ -44,7 +43,7 @@
*/
public abstract class Parameters<S extends Parameters<S, T>, T extends Parameter> implements Streamable<T> {

public static final List<Class<?>> TYPES = Arrays.asList(ScrollPosition.class, Pageable.class, Sort.class,
public static final List<Class<?>> TYPES = List.of(ScrollPosition.class, Pageable.class, Sort.class,
Limit.class);

private static final String PARAM_ON_SPECIAL = format("You must not use @%s on a parameter typed %s or %s",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@

import java.beans.PropertyDescriptor;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
Expand Down Expand Up @@ -224,7 +222,7 @@ public List<String> getInputProperties() {
*/
private static final class ReturnedClass extends ReturnedType {

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

private final Class<?> type;
private final boolean isDto;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
package org.springframework.data.repository.query;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
Expand Down Expand Up @@ -301,7 +300,7 @@ Map<String, String> getParameterMap() {
*/
static class QuotationMap {

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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
package org.springframework.data.repository.query;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
Expand Down Expand Up @@ -345,7 +344,7 @@ public Map<String, ValueExpression> getParameterMap() {
*/
static class QuotationMap {

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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
package org.springframework.data.repository.query.parser;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Optional;
import java.util.Set;
Expand Down Expand Up @@ -46,7 +44,7 @@ class OrderBySource {
private static final String BLOCK_SPLIT = "(?<=Asc|Desc)(?=\\p{Lu})";
private static final Pattern DIRECTION_SPLIT = Pattern.compile("(.+?)(Asc|Desc)?$");
private static final String INVALID_ORDER_SYNTAX = "Invalid order syntax for part %s";
private static final Set<String> DIRECTION_KEYWORDS = new HashSet<>(Arrays.asList("Asc", "Desc"));
private static final Set<String> DIRECTION_KEYWORDS = Set.of("Asc", "Desc");

private final List<Order> orders;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public static enum Type {

// Need to list them again explicitly as the order is important
// (esp. for IS_NULL, IS_NOT_NULL)
private static final List<Part.Type> ALL = Arrays.asList(IS_NOT_NULL, IS_NULL, BETWEEN, LESS_THAN, LESS_THAN_EQUAL,
private static final List<Part.Type> ALL = List.of(IS_NOT_NULL, IS_NULL, BETWEEN, LESS_THAN, LESS_THAN_EQUAL,
GREATER_THAN, GREATER_THAN_EQUAL, BEFORE, AFTER, NOT_LIKE, LIKE, STARTING_WITH, ENDING_WITH, IS_NOT_EMPTY,
IS_EMPTY, NOT_CONTAINING, CONTAINING, NOT_IN, IN, NEAR, WITHIN, REGEX, EXISTS, TRUE, FALSE,
NEGATING_SIMPLE_PROPERTY, SIMPLE_PROPERTY);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
import java.lang.reflect.AnnotatedElement;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
Expand Down Expand Up @@ -88,8 +86,8 @@ public abstract class NullableUtils {
private static final Set<Class<?>> NON_NULLABLE_ANNOTATIONS = findClasses("reactor.util.lang.NonNullApi",
NonNullApi.class.getName());

private static final Set<String> WHEN_NULLABLE = new HashSet<>(Arrays.asList("UNKNOWN", "MAYBE", "NEVER"));
private static final Set<String> WHEN_NON_NULLABLE = new HashSet<>(Collections.singletonList("ALWAYS"));
private static final Set<String> WHEN_NULLABLE = Set.of("UNKNOWN", "MAYBE", "NEVER");
private static final Set<String> WHEN_NON_NULLABLE = Set.of("ALWAYS");

private NullableUtils() {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,9 @@ public class TypeCollector {

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

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

private final Predicate<Class<?>> excludedDomainsFilter = type -> {
String packageName = type.getPackageName() + ".";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
public class ProxyingHandlerMethodArgumentResolver extends ModelAttributeMethodProcessor
implements BeanFactoryAware, BeanClassLoaderAware {

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

private final SpelAwareProxyProjectionFactory proxyFactory;
private final ObjectFactory<ConversionService> conversionService;
Expand Down
Loading