Skip to content

Commit

Permalink
Enforce using List.of(...) instead of Arrays.asList(...)
Browse files Browse the repository at this point in the history
  • Loading branch information
quaff committed Apr 8, 2024
1 parent c3c82bd commit 573e195
Show file tree
Hide file tree
Showing 326 changed files with 807 additions and 994 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package org.springframework.boot.build;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -128,7 +127,7 @@ private void configureJarManifestConventions(Project project) {
ExtractResources extractLegalResources = project.getTasks()
.create("extractLegalResources", ExtractResources.class);
extractLegalResources.getDestinationDirectory().set(project.getLayout().getBuildDirectory().dir("legal"));
extractLegalResources.setResourcesNames(Arrays.asList("LICENSE.txt", "NOTICE.txt"));
extractLegalResources.setResourcesNames(List.of("LICENSE.txt", "NOTICE.txt"));
extractLegalResources.property("version", project.getVersion().toString());
SourceSetContainer sourceSets = project.getExtensions().getByType(SourceSetContainer.class);
Set<String> sourceJarTaskNames = sourceSets.stream()
Expand Down Expand Up @@ -224,7 +223,7 @@ private void configureJavaConventions(Project project) {
compile.setTargetCompatibility(SOURCE_AND_TARGET_COMPATIBILITY);
}
else if (buildingWithJava17(project)) {
args.addAll(Arrays.asList("-Werror", "-Xlint:unchecked", "-Xlint:deprecation", "-Xlint:rawtypes",
args.addAll(List.of("-Werror", "-Xlint:unchecked", "-Xlint:deprecation", "-Xlint:rawtypes",
"-Xlint:varargs"));
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import java.net.URI;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Properties;
import java.util.Set;
Expand Down Expand Up @@ -120,7 +119,7 @@ private void applyUpgrades(GitHubRepository repository, List<String> issueLabels
int issueNumber = getOrOpenUpgradeIssue(repository, issueLabels, milestone, title,
existingUpgradeIssue);
if (existingUpgradeIssue != null && existingUpgradeIssue.getState() == Issue.State.CLOSED) {
existingUpgradeIssue.label(Arrays.asList("type: task", "status: superseded"));
existingUpgradeIssue.label(List.of("type: task", "status: superseded"));
}
System.out.println(" Issue: " + issueNumber + " - " + title
+ getExistingUpgradeIssueMessageDetails(existingUpgradeIssue));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package org.springframework.boot.build.bom.bomr.version;

import java.util.Arrays;
import java.util.List;
import java.util.function.Function;

Expand Down Expand Up @@ -62,7 +61,7 @@ public interface DependencyVersion extends Comparable<DependencyVersion> {
boolean isSnapshotFor(DependencyVersion candidate);

static DependencyVersion parse(String version) {
List<Function<String, DependencyVersion>> parsers = Arrays.asList(CalendarVersionDependencyVersion::parse,
List<Function<String, DependencyVersion>> parsers = List.of(CalendarVersionDependencyVersion::parse,
ArtifactVersionDependencyVersion::parse, ReleaseTrainDependencyVersion::parse,
MultipleComponentsDependencyVersion::parse, CombinedPatchAndQualifierDependencyVersion::parse,
LeadingZeroesDependencyVersion::parse, UnstructuredDependencyVersion::parse);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
Expand Down Expand Up @@ -101,8 +100,8 @@ public void ignore(Predicate<String> predicate) {

private static final class ClasspathContents {

private static final Set<String> IGNORED_NAMES = new HashSet<>(Arrays.asList("about.html", "changelog.txt",
"LICENSE", "license.txt", "module-info.class", "notice.txt", "readme.txt"));
private static final Set<String> IGNORED_NAMES = new HashSet<>(List.of("about.html", "changelog.txt", "LICENSE",
"license.txt", "module-info.class", "notice.txt", "readme.txt"));

private final Map<String, List<String>> classpathContents = new HashMap<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.util.Arrays;
import java.util.List;
import java.util.Properties;
import java.util.function.BiConsumer;

Expand Down Expand Up @@ -215,7 +215,7 @@ private SourceSet getMainSourceSet(Project project) {

private void setJavadocOptions(Javadoc javadoc) {
StandardJavadocDocletOptions options = (StandardJavadocDocletOptions) javadoc.getOptions();
options.addMultilineStringsOption("tag").setValue(Arrays.asList("goal:X", "requiresProject:X", "threadSafe:X"));
options.addMultilineStringsOption("tag").setValue(List.of("goal:X", "requiresProject:X", "threadSafe:X"));
}

private FormatHelpMojoSource createFormatHelpMojoSource(Project project, MavenExec generateHelpMojoTask,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
package org.springframework.boot.build.mavenplugin;

import java.io.File;
import java.util.Arrays;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;

import org.gradle.api.DefaultTask;
Expand Down Expand Up @@ -54,7 +54,7 @@ public Set<String> getVersions() {
}

public void versions(String... versions) {
this.versions.addAll(Arrays.asList(versions));
this.versions.addAll(List.of(versions));
}

@TaskAction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
Expand Down Expand Up @@ -150,8 +150,8 @@ private boolean isProduction() {
}

private boolean isTechnical() {
return !Arrays.asList("spring-boot-starter", "spring-boot-starter-test").contains(this.name)
&& !isProduction() && !this.dependencies.contains("spring-boot-starter");
return !List.of("spring-boot-starter", "spring-boot-starter-test").contains(this.name) && !isProduction()
&& !this.dependencies.contains("spring-boot-starter");
}

private boolean isApplication() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package org.springframework.boot.build.context.properties;

import java.io.File;
import java.util.Arrays;
import java.util.List;

import org.junit.jupiter.api.Test;

Expand All @@ -33,7 +33,7 @@ class ConfigurationPropertiesTests {
@Test
void whenJsonHasAnIntegerDefaultValueThenItRemainsAnIntegerWhenRead() {
ConfigurationProperties properties = ConfigurationProperties
.fromFiles(Arrays.asList(new File("src/test/resources/spring-configuration-metadata.json")));
.fromFiles(List.of(new File("src/test/resources/spring-configuration-metadata.json")));
assertThat(properties.get("example.counter").getDefaultValue()).isEqualTo(0);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

package org.springframework.boot.actuate.autoconfigure.availability;

import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import org.springframework.boot.actuate.endpoint.SecurityContext;
Expand All @@ -39,7 +39,7 @@ class AvailabilityProbesHealthEndpointGroup implements HealthEndpointGroup {
private final AdditionalHealthEndpointPath additionalPath;

AvailabilityProbesHealthEndpointGroup(AdditionalHealthEndpointPath additionalPath, String... members) {
this.members = new HashSet<>(Arrays.asList(members));
this.members = new HashSet<>(List.of(members));
this.additionalPath = additionalPath;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package org.springframework.boot.actuate.autoconfigure.cloudfoundry;

import java.util.Arrays;
import java.util.List;

/**
Expand Down Expand Up @@ -46,7 +45,7 @@ public enum AccessLevel {
private final List<String> ids;

AccessLevel(String... ids) {
this.ids = Arrays.asList(ids);
this.ids = List.of(ids);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package org.springframework.boot.actuate.autoconfigure.cloudfoundry.reactive;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
Expand Down Expand Up @@ -145,9 +144,9 @@ private ReactiveCloudFoundrySecurityService getCloudFoundrySecurityService(WebCl
private CorsConfiguration getCorsConfiguration() {
CorsConfiguration corsConfiguration = new CorsConfiguration();
corsConfiguration.addAllowedOrigin(CorsConfiguration.ALL);
corsConfiguration.setAllowedMethods(Arrays.asList(HttpMethod.GET.name(), HttpMethod.POST.name()));
corsConfiguration.setAllowedMethods(List.of(HttpMethod.GET.name(), HttpMethod.POST.name()));
corsConfiguration
.setAllowedHeaders(Arrays.asList(HttpHeaders.AUTHORIZATION, "X-Cf-App-Instance", HttpHeaders.CONTENT_TYPE));
.setAllowedHeaders(List.of(HttpHeaders.AUTHORIZATION, "X-Cf-App-Instance", HttpHeaders.CONTENT_TYPE));
return corsConfiguration;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package org.springframework.boot.actuate.autoconfigure.cloudfoundry.servlet;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
Expand Down Expand Up @@ -149,9 +148,9 @@ private CloudFoundrySecurityService getCloudFoundrySecurityService(RestTemplateB
private CorsConfiguration getCorsConfiguration() {
CorsConfiguration corsConfiguration = new CorsConfiguration();
corsConfiguration.addAllowedOrigin(CorsConfiguration.ALL);
corsConfiguration.setAllowedMethods(Arrays.asList(HttpMethod.GET.name(), HttpMethod.POST.name()));
corsConfiguration.setAllowedMethods(List.of(HttpMethod.GET.name(), HttpMethod.POST.name()));
corsConfiguration
.setAllowedHeaders(Arrays.asList(HttpHeaders.AUTHORIZATION, "X-Cf-App-Instance", HttpHeaders.CONTENT_TYPE));
.setAllowedHeaders(List.of(HttpHeaders.AUTHORIZATION, "X-Cf-App-Instance", HttpHeaders.CONTENT_TYPE));
return corsConfiguration;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@

package org.springframework.boot.actuate.autoconfigure.endpoint.condition;

import java.util.Arrays;
import java.util.EnumSet;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
Expand Down Expand Up @@ -151,8 +151,7 @@ private Boolean isEnabledByDefault(Environment environment) {
private Set<EndpointExposure> getExposuresToCheck(
MergedAnnotation<ConditionalOnAvailableEndpoint> conditionAnnotation) {
EndpointExposure[] exposure = conditionAnnotation.getEnumArray("exposure", EndpointExposure.class);
return (exposure.length == 0) ? EnumSet.allOf(EndpointExposure.class)
: new LinkedHashSet<>(Arrays.asList(exposure));
return (exposure.length == 0) ? EnumSet.allOf(EndpointExposure.class) : new LinkedHashSet<>(List.of(exposure));
}

private Set<ExposureFilter> getExposureFilters(Environment environment) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package org.springframework.boot.actuate.autoconfigure.endpoint.expose;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashSet;
Expand Down Expand Up @@ -150,7 +149,7 @@ private static class EndpointPatterns {
private final Set<EndpointId> endpointIds;

EndpointPatterns(String[] patterns) {
this((patterns != null) ? Arrays.asList(patterns) : null);
this((patterns != null) ? List.of(patterns) : null);
}

EndpointPatterns(Collection<String> patterns) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package org.springframework.boot.actuate.autoconfigure.endpoint.web.reactive;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
Expand Down Expand Up @@ -152,7 +151,7 @@ static ServerCodecConfigurerEndpointObjectMapperBeanPostProcessor serverCodecCon
static class ServerCodecConfigurerEndpointObjectMapperBeanPostProcessor implements BeanPostProcessor {

private static final List<MediaType> MEDIA_TYPES = Collections
.unmodifiableList(Arrays.asList(MediaType.APPLICATION_JSON, new MediaType("application", "*+json")));
.unmodifiableList(List.of(MediaType.APPLICATION_JSON, new MediaType("application", "*+json")));

private final Supplier<EndpointObjectMapper> endpointObjectMapper;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package org.springframework.boot.actuate.autoconfigure.endpoint.web.servlet;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
Expand Down Expand Up @@ -147,7 +146,7 @@ static EndpointObjectMapperWebMvcConfigurer endpointObjectMapperWebMvcConfigurer
static class EndpointObjectMapperWebMvcConfigurer implements WebMvcConfigurer {

private static final List<MediaType> MEDIA_TYPES = Collections
.unmodifiableList(Arrays.asList(MediaType.APPLICATION_JSON, new MediaType("application", "*+json")));
.unmodifiableList(List.of(MediaType.APPLICATION_JSON, new MediaType("application", "*+json")));

private final EndpointObjectMapper endpointObjectMapper;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package org.springframework.boot.actuate.autoconfigure.security.reactive;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.List;
Expand Down Expand Up @@ -162,11 +161,11 @@ private EndpointServerWebExchangeMatcher(boolean includeLinks) {
}

private EndpointServerWebExchangeMatcher(Class<?>[] endpoints, boolean includeLinks) {
this(Arrays.asList((Object[]) endpoints), Collections.emptyList(), includeLinks);
this(List.of((Object[]) endpoints), Collections.emptyList(), includeLinks);
}

private EndpointServerWebExchangeMatcher(String[] endpoints, boolean includeLinks) {
this(Arrays.asList((Object[]) endpoints), Collections.emptyList(), includeLinks);
this(List.of((Object[]) endpoints), Collections.emptyList(), includeLinks);
}

private EndpointServerWebExchangeMatcher(List<Object> includes, List<Object> excludes, boolean includeLinks) {
Expand All @@ -178,13 +177,13 @@ private EndpointServerWebExchangeMatcher(List<Object> includes, List<Object> exc

public EndpointServerWebExchangeMatcher excluding(Class<?>... endpoints) {
List<Object> excludes = new ArrayList<>(this.excludes);
excludes.addAll(Arrays.asList((Object[]) endpoints));
excludes.addAll(List.of((Object[]) endpoints));
return new EndpointServerWebExchangeMatcher(this.includes, excludes, this.includeLinks);
}

public EndpointServerWebExchangeMatcher excluding(String... endpoints) {
List<Object> excludes = new ArrayList<>(this.excludes);
excludes.addAll(Arrays.asList((Object[]) endpoints));
excludes.addAll(List.of((Object[]) endpoints));
return new EndpointServerWebExchangeMatcher(this.includes, excludes, this.includeLinks);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package org.springframework.boot.actuate.autoconfigure.security.servlet;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.List;
Expand Down Expand Up @@ -196,11 +195,11 @@ private EndpointRequestMatcher(boolean includeLinks) {
}

private EndpointRequestMatcher(Class<?>[] endpoints, boolean includeLinks) {
this(Arrays.asList((Object[]) endpoints), Collections.emptyList(), includeLinks);
this(List.of((Object[]) endpoints), Collections.emptyList(), includeLinks);
}

private EndpointRequestMatcher(String[] endpoints, boolean includeLinks) {
this(Arrays.asList((Object[]) endpoints), Collections.emptyList(), includeLinks);
this(List.of((Object[]) endpoints), Collections.emptyList(), includeLinks);
}

private EndpointRequestMatcher(List<Object> includes, List<Object> excludes, boolean includeLinks) {
Expand All @@ -211,13 +210,13 @@ private EndpointRequestMatcher(List<Object> includes, List<Object> excludes, boo

public EndpointRequestMatcher excluding(Class<?>... endpoints) {
List<Object> excludes = new ArrayList<>(this.excludes);
excludes.addAll(Arrays.asList((Object[]) endpoints));
excludes.addAll(List.of((Object[]) endpoints));
return new EndpointRequestMatcher(this.includes, excludes, this.includeLinks);
}

public EndpointRequestMatcher excluding(String... endpoints) {
List<Object> excludes = new ArrayList<>(this.excludes);
excludes.addAll(Arrays.asList((Object[]) endpoints));
excludes.addAll(List.of((Object[]) endpoints));
return new EndpointRequestMatcher(this.includes, excludes, this.includeLinks);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package org.springframework.boot.actuate.autoconfigure.tracing;

import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
Expand Down Expand Up @@ -58,7 +57,7 @@ default Spliterator<SpanExporter> spliterator() {
* @return the constructed {@link SpanExporters} instance
*/
static SpanExporters of(SpanExporter... spanExporters) {
return of(Arrays.asList(spanExporters));
return of(List.of(spanExporters));
}

/**
Expand Down
Loading

0 comments on commit 573e195

Please sign in to comment.