-
Notifications
You must be signed in to change notification settings - Fork 41.7k
Description
Using a for loop to add elements to a collection could be replaced in the instances below by use of the Collections.addAll method. This method does the same thing but the for loop does not need to be duplicated in the Spring Boot code base to achieve the same result.
org.springframework.boot.actuate.metrics.reader.CompositeMetricReader
public CompositeMetricReader(MetricReader... readers) {
for (MetricReader reader : readers) {
this.readers.add(reader);
}
}
to
Collections.addAll(this.readers, readers);
org.springframework.boot.actuate.metrics.writer.CompositeMetricWriter
public CompositeMetricWriter(MetricWriter... writers) {
for (MetricWriter writer : writers) {
this.writers.add(writer);
}
}
to
Collections.addAll(this.writers, writers);
org.springframework.boot.loader.ExecutableArchiveLauncher.createClassLoader(URL[])
for (URL url : urls) {
copy.add(url);
}
to
Collections.addAll(copy, urls);
org.springframework.boot.context.embedded.FilterRegistrationBean(Filter, ServletRegistrationBean...)
for (ServletRegistrationBean servletRegistrationBean : servletRegistrationBeans) {
this.servletRegistrationBeans.add(servletRegistrationBean);
}
to
Collections.addAll(this.servletRegistrationBeans, servletRegistrationBeans);
org.springframework.boot.context.embedded.FilterRegistrationBean.addServletRegistrationBeans(ServletRegistrationBean...)
for (ServletRegistrationBean servletRegistrationBean : servletRegistrationBeans) {
this.servletRegistrationBeans.add(servletRegistrationBean);
}
to
Collections.addAll(this.servletRegistrationBeans, servletRegistrationBeans);
org.springframework.boot.context.embedded.FilterRegistrationBean.addUrlPatterns(String...)
for (String urlPattern : urlPatterns) {
this.urlPatterns.add(urlPattern);
}
to
Collections.addAll(this.urlPatterns, urlPatterns);
org.springframework.boot.autoconfigure.condition.BeanSearchSpec.collect(MultiValueMap<String, Object>, String key, List)
for (String value : valueArray) {
destination.add(value);
}
to
Collections.addAll(destination, valueArray);
org.springframework.boot.yaml.SpringProfileDocumentMatcher.addActiveProfiles(String...)
for (String profile : profiles) {
set.add(profile);
}
to
Collections.addAll(set, profiles);
org.springframework.boot.cli.command.core.HintCommand.run(String...)
for (int i = 2; i < args.length; i++) {
arguments.add(args[i]);
}
to
arguments.addAll(Arrays.asList(args).subList(2, args.length));