Skip to content

Commit 55b1685

Browse files
committed
GH-69 - Switch to Stream.toList().
1 parent d96263f commit 55b1685

File tree

16 files changed

+27
-34
lines changed

16 files changed

+27
-34
lines changed

spring-modulith-core/src/main/java/org/springframework/modulith/model/ApplicationModuleInformation.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import java.util.List;
2121
import java.util.Optional;
2222
import java.util.function.Supplier;
23-
import java.util.stream.Collectors;
2423
import java.util.stream.Stream;
2524

2625
import org.springframework.modulith.ApplicationModule;
@@ -125,7 +124,7 @@ public List<String> getAllowedDependencies() {
125124
return annotation //
126125
.map(it -> Arrays.stream(it.allowedDependencies())) //
127126
.orElse(Stream.empty()) //
128-
.collect(Collectors.toList());
127+
.toList();
129128
}
130129
}
131130
}

spring-modulith-core/src/main/java/org/springframework/modulith/model/ApplicationModules.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ private ApplicationModules(ModulithMetadata metadata, Collection<String> package
102102

103103
this.rootPackages = packages.stream() //
104104
.map(it -> JavaPackage.of(classes, it).toSingle()) //
105-
.collect(Collectors.toList());
105+
.toList();
106106

107107
this.sharedModules = Collections.emptySet();
108108
}

spring-modulith-core/src/main/java/org/springframework/modulith/model/Classes.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ private Classes(List<JavaClass> classes) {
7777
static Classes of(JavaClasses classes) {
7878

7979
return new Classes(StreamSupport.stream(classes.spliterator(), false) //
80-
.collect(Collectors.toList()));
80+
.toList());
8181
}
8282

8383
/**

spring-modulith-core/src/main/java/org/springframework/modulith/model/EventType.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,10 @@
1818
import lombok.Value;
1919

2020
import java.util.List;
21-
import java.util.stream.Collectors;
2221
import java.util.stream.Stream;
2322

2423
import org.springframework.util.Assert;
2524

26-
import com.tngtech.archunit.core.domain.JavaAccess;
2725
import com.tngtech.archunit.core.domain.JavaClass;
2826
import com.tngtech.archunit.core.domain.JavaModifier;
2927

@@ -54,18 +52,18 @@ public EventType(JavaClass type) {
5452

5553
this.type = type;
5654

57-
Stream<JavaAccess<?>> factoryMethodCalls = type.getMethods().stream()
55+
var factoryMethodCalls = type.getMethods().stream()
5856
.filter(method -> method.getModifiers().contains(JavaModifier.STATIC))
5957
.filter(method -> method.getRawReturnType().equals(type))
6058
.flatMap(method -> method.getCallsOfSelf().stream());
6159

62-
Stream<JavaAccess<?>> constructorCalls = type.getConstructors().stream()
60+
var constructorCalls = type.getConstructors().stream()
6361
.flatMap(constructor -> constructor.getCallsOfSelf().stream());
6462

6563
this.sources = Stream.concat(constructorCalls, factoryMethodCalls)
6664
.filter(call -> !call.getOriginOwner().equals(type))
67-
.map(JavaAccessSource::new)
68-
.collect(Collectors.toList());
65+
.<Source> map(JavaAccessSource::new)
66+
.toList();
6967
}
7068

7169
public boolean hasSources() {

spring-modulith-core/src/main/java/org/springframework/modulith/model/NamedInterface.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import java.util.Arrays;
2323
import java.util.Iterator;
2424
import java.util.List;
25-
import java.util.stream.Collectors;
2625

2726
import org.springframework.util.Assert;
2827

@@ -56,7 +55,7 @@ public static List<PackageBasedNamedInterface> of(JavaPackage javaPackage) {
5655

5756
return Arrays.stream(name) //
5857
.map(it -> new PackageBasedNamedInterface(it, javaPackage)) //
59-
.collect(Collectors.toList());
58+
.toList();
6059
}
6160

6261
public static TypeBasedNamedInterface of(String name, Classes classes, JavaPackage basePackage) {

spring-modulith-core/src/main/java/org/springframework/modulith/model/NamedInterfaces.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ private static List<TypeBasedNamedInterface> ofAnnotatedTypes(JavaPackage basePa
8484

8585
return mappings.entrySet().stream() //
8686
.map(entry -> NamedInterface.of(entry.getKey(), Classes.of(entry.getValue()), basePackage)) //
87-
.collect(Collectors.toList());
87+
.toList();
8888
}
8989

9090
private NamedInterfaces and(NamedInterface namedInterface) {

spring-modulith-core/src/main/java/org/springframework/modulith/model/SpringBean.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import lombok.RequiredArgsConstructor;
2222

2323
import java.util.List;
24-
import java.util.stream.Collectors;
2524

2625
import com.tngtech.archunit.core.domain.JavaClass;
2726

@@ -65,7 +64,7 @@ public List<JavaClass> getInterfacesWithinModule() {
6564

6665
return type.getRawInterfaces().stream() //
6766
.filter(module::contains) //
68-
.collect(Collectors.toList());
67+
.toList();
6968
}
7069

7170
public boolean isAnnotatedWith(Class<?> type) {

spring-modulith-docs/src/main/java/org/springframework/modulith/docs/ConfigurationProperties.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class ConfigurationProperties implements Iterable<ConfigurationProperty> {
6262

6363
this.properties = Arrays.stream(resources)
6464
.flatMap(ConfigurationProperties::parseProperties)
65-
.collect(Collectors.toList());
65+
.toList();
6666

6767
} catch (IOException e) {
6868
throw new RuntimeException(e);
@@ -81,7 +81,7 @@ public List<ModuleProperty> getModuleProperties(ApplicationModule module) {
8181

8282
return properties.stream()
8383
.flatMap(it -> getModuleProperty(module, it))
84-
.collect(Collectors.toList());
84+
.toList();
8585
}
8686

8787
/*

spring-modulith-docs/src/main/java/org/springframework/modulith/docs/Documenter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -822,7 +822,7 @@ private List<SpringBean> getMatchingBeans(ApplicationModule module, Grouping fil
822822
.filter(it -> !hideInternals || it.isApiBean())
823823
.filter(it -> !alreadyMapped.contains(it))
824824
.filter(filter::matches)
825-
.collect(Collectors.toList());
825+
.toList();
826826
}
827827

828828
@Value(staticConstructor = "of")

spring-modulith-events/spring-modulith-events-core/src/main/java/org/springframework/modulith/events/support/PersistentApplicationEventMulticaster.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import java.util.List;
2424
import java.util.function.Consumer;
2525
import java.util.function.Supplier;
26-
import java.util.stream.Collectors;
2726
import java.util.stream.Stream;
2827

2928
import org.springframework.beans.factory.SmartInitializingSingleton;
@@ -165,7 +164,7 @@ public TransactionalEventListeners(Collection<ApplicationListener<?>> listeners)
165164
.filter(TransactionalApplicationListener.class::isInstance)
166165
.map(TransactionalApplicationListener.class::cast)
167166
.sorted(AnnotationAwareOrderComparator.INSTANCE)
168-
.collect(Collectors.toList());
167+
.toList();
169168
}
170169

171170
private TransactionalEventListeners(
@@ -185,7 +184,7 @@ public TransactionalEventListeners forPhase(TransactionPhase phase) {
185184

186185
List<TransactionalApplicationListener<ApplicationEvent>> collect = listeners.stream()
187186
.filter(it -> it.getTransactionPhase().equals(phase))
188-
.collect(Collectors.toList());
187+
.toList();
189188

190189
return new TransactionalEventListeners(collect);
191190
}

0 commit comments

Comments
 (0)