GH-69 - Switch to Stream.toList().

This commit is contained in:
Oliver Drotbohm
2022-11-11 18:38:53 +01:00
parent d96263fe30
commit 55b16857f3
16 changed files with 27 additions and 34 deletions

View File

@@ -20,7 +20,6 @@ import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.springframework.modulith.ApplicationModule;
@@ -125,7 +124,7 @@ interface ApplicationModuleInformation {
return annotation //
.map(it -> Arrays.stream(it.allowedDependencies())) //
.orElse(Stream.empty()) //
.collect(Collectors.toList());
.toList();
}
}
}

View File

@@ -102,7 +102,7 @@ public class ApplicationModules implements Iterable<ApplicationModule> {
this.rootPackages = packages.stream() //
.map(it -> JavaPackage.of(classes, it).toSingle()) //
.collect(Collectors.toList());
.toList();
this.sharedModules = Collections.emptySet();
}

View File

@@ -77,7 +77,7 @@ class Classes implements DescribedIterable<JavaClass> {
static Classes of(JavaClasses classes) {
return new Classes(StreamSupport.stream(classes.spliterator(), false) //
.collect(Collectors.toList()));
.toList());
}
/**

View File

@@ -18,12 +18,10 @@ package org.springframework.modulith.model;
import lombok.Value;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.springframework.util.Assert;
import com.tngtech.archunit.core.domain.JavaAccess;
import com.tngtech.archunit.core.domain.JavaClass;
import com.tngtech.archunit.core.domain.JavaModifier;
@@ -54,18 +52,18 @@ public class EventType {
this.type = type;
Stream<JavaAccess<?>> factoryMethodCalls = type.getMethods().stream()
var factoryMethodCalls = type.getMethods().stream()
.filter(method -> method.getModifiers().contains(JavaModifier.STATIC))
.filter(method -> method.getRawReturnType().equals(type))
.flatMap(method -> method.getCallsOfSelf().stream());
Stream<JavaAccess<?>> constructorCalls = type.getConstructors().stream()
var constructorCalls = type.getConstructors().stream()
.flatMap(constructor -> constructor.getCallsOfSelf().stream());
this.sources = Stream.concat(constructorCalls, factoryMethodCalls)
.filter(call -> !call.getOriginOwner().equals(type))
.map(JavaAccessSource::new)
.collect(Collectors.toList());
.<Source> map(JavaAccessSource::new)
.toList();
}
public boolean hasSources() {

View File

@@ -22,7 +22,6 @@ import lombok.RequiredArgsConstructor;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.stream.Collectors;
import org.springframework.util.Assert;
@@ -56,7 +55,7 @@ public abstract class NamedInterface implements Iterable<JavaClass> {
return Arrays.stream(name) //
.map(it -> new PackageBasedNamedInterface(it, javaPackage)) //
.collect(Collectors.toList());
.toList();
}
public static TypeBasedNamedInterface of(String name, Classes classes, JavaPackage basePackage) {

View File

@@ -84,7 +84,7 @@ public class NamedInterfaces implements Iterable<NamedInterface> {
return mappings.entrySet().stream() //
.map(entry -> NamedInterface.of(entry.getKey(), Classes.of(entry.getValue()), basePackage)) //
.collect(Collectors.toList());
.toList();
}
private NamedInterfaces and(NamedInterface namedInterface) {

View File

@@ -21,7 +21,6 @@ import lombok.Getter;
import lombok.RequiredArgsConstructor;
import java.util.List;
import java.util.stream.Collectors;
import com.tngtech.archunit.core.domain.JavaClass;
@@ -65,7 +64,7 @@ public class SpringBean {
return type.getRawInterfaces().stream() //
.filter(module::contains) //
.collect(Collectors.toList());
.toList();
}
public boolean isAnnotatedWith(Class<?> type) {