Use List.of() and Set.of() where feasible
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2022 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.
|
||||
@@ -97,7 +97,7 @@ public abstract class YamlProcessor {
|
||||
* </pre>
|
||||
*/
|
||||
public void setDocumentMatchers(DocumentMatcher... matchers) {
|
||||
this.documentMatchers = Arrays.asList(matchers);
|
||||
this.documentMatchers = List.of(matchers);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -552,7 +552,7 @@ public class GroovyBeanDefinitionReader extends AbstractBeanDefinitionReader imp
|
||||
constructorArgs[i] = manageMapIfNecessary(map);
|
||||
}
|
||||
}
|
||||
return Arrays.asList(constructorArgs);
|
||||
return List.of(constructorArgs);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2022 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.
|
||||
@@ -47,7 +47,7 @@ import org.springframework.core.Ordered;
|
||||
* public CacheManager cacheManager() {
|
||||
* // configure and return an implementation of Spring's CacheManager SPI
|
||||
* SimpleCacheManager cacheManager = new SimpleCacheManager();
|
||||
* cacheManager.setCaches(Arrays.asList(new ConcurrentMapCache("default")));
|
||||
* cacheManager.setCaches(Set.of(new ConcurrentMapCache("default")));
|
||||
* return cacheManager;
|
||||
* }
|
||||
* }</pre>
|
||||
@@ -116,7 +116,7 @@ import org.springframework.core.Ordered;
|
||||
* public CacheManager cacheManager() {
|
||||
* // configure and return an implementation of Spring's CacheManager SPI
|
||||
* SimpleCacheManager cacheManager = new SimpleCacheManager();
|
||||
* cacheManager.setCaches(Arrays.asList(new ConcurrentMapCache("default")));
|
||||
* cacheManager.setCaches(Set.of(new ConcurrentMapCache("default")));
|
||||
* return cacheManager;
|
||||
* }
|
||||
*
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2022 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.
|
||||
@@ -16,9 +16,8 @@
|
||||
|
||||
package org.springframework.cache.interceptor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.cache.CacheManager;
|
||||
import org.springframework.lang.Nullable;
|
||||
@@ -41,7 +40,7 @@ public class NamedCacheResolver extends AbstractCacheResolver {
|
||||
|
||||
public NamedCacheResolver(CacheManager cacheManager, String... cacheNames) {
|
||||
super(cacheManager);
|
||||
this.cacheNames = new ArrayList<>(Arrays.asList(cacheNames));
|
||||
this.cacheNames = List.of(cacheNames);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2022 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.
|
||||
@@ -19,7 +19,6 @@ package org.springframework.scheduling.annotation;
|
||||
import java.lang.reflect.Method;
|
||||
import java.time.Duration;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.IdentityHashMap;
|
||||
@@ -361,7 +360,7 @@ public class ScheduledAnnotationBeanPostProcessor
|
||||
|
||||
Class<?> targetClass = AopProxyUtils.ultimateTargetClass(bean);
|
||||
if (!this.nonAnnotatedClasses.contains(targetClass) &&
|
||||
AnnotationUtils.isCandidateClass(targetClass, Arrays.asList(Scheduled.class, Schedules.class))) {
|
||||
AnnotationUtils.isCandidateClass(targetClass, List.of(Scheduled.class, Schedules.class))) {
|
||||
Map<Method, Set<Scheduled>> annotatedMethods = MethodIntrospector.selectMethods(targetClass,
|
||||
(MethodIntrospector.MetadataLookup<Set<Scheduled>>) method -> {
|
||||
Set<Scheduled> scheduledAnnotations = AnnotatedElementUtils.getMergedRepeatableAnnotations(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2022 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.
|
||||
@@ -20,7 +20,6 @@ import java.nio.CharBuffer;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -64,7 +63,7 @@ public final class StringDecoder extends AbstractDataBufferDecoder<String> {
|
||||
public static final Charset DEFAULT_CHARSET = StandardCharsets.UTF_8;
|
||||
|
||||
/** The default delimiter strings to use, i.e. {@code \r\n} and {@code \n}. */
|
||||
public static final List<String> DEFAULT_DELIMITERS = Arrays.asList("\r\n", "\n");
|
||||
public static final List<String> DEFAULT_DELIMITERS = List.of("\r\n", "\n");
|
||||
|
||||
|
||||
private final List<String> delimiters;
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package org.springframework.mock.web;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
@@ -94,7 +93,7 @@ public class MockFilterChain implements FilterChain {
|
||||
|
||||
private static List<Filter> initFilterList(Servlet servlet, Filter... filters) {
|
||||
Filter[] allFilters = ObjectUtils.addObjectToArray(filters, new ServletFilterProxy(servlet));
|
||||
return Arrays.asList(allFilters);
|
||||
return List.of(allFilters);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2022 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.
|
||||
@@ -97,7 +97,7 @@ public class SpringExtension implements BeforeAllCallback, AfterAllCallback, Tes
|
||||
// Note that @Test, @TestFactory, @TestTemplate, @RepeatedTest, and @ParameterizedTest
|
||||
// are all meta-annotated with @Testable.
|
||||
private static final List<Class<? extends Annotation>> JUPITER_ANNOTATION_TYPES =
|
||||
Arrays.asList(BeforeAll.class, AfterAll.class, BeforeEach.class, AfterEach.class, Testable.class);
|
||||
List.of(BeforeAll.class, AfterAll.class, BeforeEach.class, AfterEach.class, Testable.class);
|
||||
|
||||
private static final MethodFilter autowiredTestOrLifecycleMethodFilter =
|
||||
ReflectionUtils.USER_DECLARED_METHODS
|
||||
|
||||
@@ -20,7 +20,6 @@ import java.net.URI;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.Duration;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -59,7 +58,7 @@ public class ExchangeResult {
|
||||
|
||||
private static final Log logger = LogFactory.getLog(ExchangeResult.class);
|
||||
|
||||
private static final List<MediaType> PRINTABLE_MEDIA_TYPES = Arrays.asList(
|
||||
private static final List<MediaType> PRINTABLE_MEDIA_TYPES = List.of(
|
||||
MediaType.parseMediaType("application/*+json"), MediaType.APPLICATION_XML,
|
||||
MediaType.parseMediaType("text/*"), MediaType.APPLICATION_FORM_URLENCODED);
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@ package org.springframework.transaction.annotation;
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.AnnotatedElement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.springframework.core.annotation.AnnotatedElementUtils;
|
||||
import org.springframework.core.annotation.AnnotationAttributes;
|
||||
@@ -81,7 +81,7 @@ public class SpringTransactionAnnotationParser implements TransactionAnnotationP
|
||||
|
||||
rbta.setReadOnly(attributes.getBoolean("readOnly"));
|
||||
rbta.setQualifier(attributes.getString("value"));
|
||||
rbta.setLabels(Arrays.asList(attributes.getStringArray("label")));
|
||||
rbta.setLabels(Set.of(attributes.getStringArray("label")));
|
||||
|
||||
List<RollbackRuleAttribute> rollbackRules = new ArrayList<>();
|
||||
for (Class<?> rbRule : attributes.getClassArray("rollbackFor")) {
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package org.springframework.web.testfixture.servlet;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
@@ -94,7 +93,7 @@ public class MockFilterChain implements FilterChain {
|
||||
|
||||
private static List<Filter> initFilterList(Servlet servlet, Filter... filters) {
|
||||
Filter[] allFilters = ObjectUtils.addObjectToArray(filters, new ServletFilterProxy(servlet));
|
||||
return Arrays.asList(allFilters);
|
||||
return List.of(allFilters);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user