Skip to content

Commit

Permalink
Redundant Collection.addAll() call
Browse files Browse the repository at this point in the history
  • Loading branch information
PiyalAhmed committed Jun 11, 2024
1 parent c470ce2 commit 277d5c0
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,7 @@ public Collection<LoadableResource> getResources(String prefix, String[] suffixe
ensureInitialized();
Predicate<LocatedResource> matchesPrefixAndSuffixes = (locatedResource) -> StringUtils
.startsAndEndsWith(locatedResource.resource.getFilename(), prefix, suffixes);
List<LoadableResource> result = new ArrayList<>();
result.addAll(this.scanner.getResources(prefix, suffixes));
List<LoadableResource> result = new ArrayList<>(this.scanner.getResources(prefix, suffixes));
this.locatedResources.stream()
.filter(matchesPrefixAndSuffixes)
.map(this::asClassPathResource)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,7 @@ static class ContextCustomizerKey {
this.key = Collections.unmodifiableSet(synthesize(annotations));
}
else {
Set<Object> key = new HashSet<>();
key.addAll(determinedImports);
Set<Object> key = new HashSet<>(determinedImports);
Set<Annotation> componentScanning = annotations.stream()
.filter((annotation) -> annotation.getType().equals(ComponentScan.class))
.map(MergedAnnotation::synthesize)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ private void registerBeanDefinitions(ConfigurableListableBeanFactory beanFactory

private Set<ServiceConnection> getAnnotations(ConfigurableListableBeanFactory beanFactory, String beanName,
BeanDefinition beanDefinition) {
Set<ServiceConnection> annotations = new LinkedHashSet<>();
annotations.addAll(beanFactory.findAllAnnotationsOnBean(beanName, ServiceConnection.class, false));
Set<ServiceConnection> annotations = new LinkedHashSet<>(beanFactory.findAllAnnotationsOnBean(beanName, ServiceConnection.class, false));
if (beanDefinition instanceof TestcontainerBeanDefinition testcontainerBeanDefinition) {
testcontainerBeanDefinition.getAnnotations()
.stream(ServiceConnection.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,7 @@ final class TldPatterns {
static final Set<String> DEFAULT_SCAN;

static {
Set<String> scanPatterns = new LinkedHashSet<>();
scanPatterns.addAll(TOMCAT_SCAN);
Set<String> scanPatterns = new LinkedHashSet<>(TOMCAT_SCAN);
DEFAULT_SCAN = Collections.unmodifiableSet(scanPatterns);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,7 @@ void setMimeMappings(MimeMappings mimeMappings) {

@Override
public String[] findMimeMappings() {
List<String> mappings = new ArrayList<>();
mappings.addAll(Arrays.asList(super.findMimeMappings()));
List<String> mappings = new ArrayList<>(Arrays.asList(super.findMimeMappings()));
if (this.mimeMappings != null) {
this.mimeMappings.forEach((mapping) -> mappings.add(mapping.getExtension()));
}
Expand Down

0 comments on commit 277d5c0

Please sign in to comment.