Polish "Use constructor rather than Collection.addAll"

See gh-41053
This commit is contained in:
Phillip Webb 2024-06-11 09:41:57 -07:00
parent 17adcfc180
commit ecc9a2352d
6 changed files with 8 additions and 9 deletions

View File

@ -71,8 +71,7 @@ public class ToolchainPlugin implements Plugin<Project> {
} }
private void configureTestToolchain(Project project, ToolchainExtension toolchain) { private void configureTestToolchain(Project project, ToolchainExtension toolchain) {
List<String> jvmArgs = new ArrayList<>(); List<String> jvmArgs = new ArrayList<>(toolchain.getTestJvmArgs().getOrElse(Collections.emptyList()));
jvmArgs.addAll(toolchain.getTestJvmArgs().getOrElse(Collections.emptyList()));
project.getTasks().withType(Test.class, (test) -> test.jvmArgs(jvmArgs)); project.getTasks().withType(Test.class, (test) -> test.jvmArgs(jvmArgs));
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2023 the original author or authors. * Copyright 2012-2024 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2023 the original author or authors. * Copyright 2012-2024 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -68,7 +68,8 @@ class ServiceConnectionAutoConfigurationRegistrar implements ImportBeanDefinitio
private Set<ServiceConnection> getAnnotations(ConfigurableListableBeanFactory beanFactory, String beanName, private Set<ServiceConnection> getAnnotations(ConfigurableListableBeanFactory beanFactory, String beanName,
BeanDefinition beanDefinition) { BeanDefinition beanDefinition) {
Set<ServiceConnection> annotations = new LinkedHashSet<>(beanFactory.findAllAnnotationsOnBean(beanName, ServiceConnection.class, false)); Set<ServiceConnection> annotations = new LinkedHashSet<>(
beanFactory.findAllAnnotationsOnBean(beanName, ServiceConnection.class, false));
if (beanDefinition instanceof TestcontainerBeanDefinition testcontainerBeanDefinition) { if (beanDefinition instanceof TestcontainerBeanDefinition testcontainerBeanDefinition) {
testcontainerBeanDefinition.getAnnotations() testcontainerBeanDefinition.getAnnotations()
.stream(ServiceConnection.class) .stream(ServiceConnection.class)

View File

@ -239,8 +239,7 @@ public final class ConfigData {
} }
private Options copy(Consumer<EnumSet<Option>> processor) { private Options copy(Consumer<EnumSet<Option>> processor) {
EnumSet<Option> options = EnumSet.noneOf(Option.class); EnumSet<Option> options = EnumSet.copyOf(this.options);
options.addAll(this.options);
processor.accept(options); processor.accept(options);
return new Options(options); return new Options(options);
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2023 the original author or authors. * Copyright 2012-2024 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2022 the original author or authors. * Copyright 2012-2024 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.