GH-69 - Switch to Stream.toList().
This commit is contained in:
@@ -20,7 +20,6 @@ import java.util.Collections;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import org.springframework.modulith.ApplicationModule;
|
import org.springframework.modulith.ApplicationModule;
|
||||||
@@ -125,7 +124,7 @@ interface ApplicationModuleInformation {
|
|||||||
return annotation //
|
return annotation //
|
||||||
.map(it -> Arrays.stream(it.allowedDependencies())) //
|
.map(it -> Arrays.stream(it.allowedDependencies())) //
|
||||||
.orElse(Stream.empty()) //
|
.orElse(Stream.empty()) //
|
||||||
.collect(Collectors.toList());
|
.toList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ public class ApplicationModules implements Iterable<ApplicationModule> {
|
|||||||
|
|
||||||
this.rootPackages = packages.stream() //
|
this.rootPackages = packages.stream() //
|
||||||
.map(it -> JavaPackage.of(classes, it).toSingle()) //
|
.map(it -> JavaPackage.of(classes, it).toSingle()) //
|
||||||
.collect(Collectors.toList());
|
.toList();
|
||||||
|
|
||||||
this.sharedModules = Collections.emptySet();
|
this.sharedModules = Collections.emptySet();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ class Classes implements DescribedIterable<JavaClass> {
|
|||||||
static Classes of(JavaClasses classes) {
|
static Classes of(JavaClasses classes) {
|
||||||
|
|
||||||
return new Classes(StreamSupport.stream(classes.spliterator(), false) //
|
return new Classes(StreamSupport.stream(classes.spliterator(), false) //
|
||||||
.collect(Collectors.toList()));
|
.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -18,12 +18,10 @@ package org.springframework.modulith.model;
|
|||||||
import lombok.Value;
|
import lombok.Value;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import org.springframework.util.Assert;
|
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.JavaClass;
|
||||||
import com.tngtech.archunit.core.domain.JavaModifier;
|
import com.tngtech.archunit.core.domain.JavaModifier;
|
||||||
|
|
||||||
@@ -54,18 +52,18 @@ public class EventType {
|
|||||||
|
|
||||||
this.type = type;
|
this.type = type;
|
||||||
|
|
||||||
Stream<JavaAccess<?>> factoryMethodCalls = type.getMethods().stream()
|
var factoryMethodCalls = type.getMethods().stream()
|
||||||
.filter(method -> method.getModifiers().contains(JavaModifier.STATIC))
|
.filter(method -> method.getModifiers().contains(JavaModifier.STATIC))
|
||||||
.filter(method -> method.getRawReturnType().equals(type))
|
.filter(method -> method.getRawReturnType().equals(type))
|
||||||
.flatMap(method -> method.getCallsOfSelf().stream());
|
.flatMap(method -> method.getCallsOfSelf().stream());
|
||||||
|
|
||||||
Stream<JavaAccess<?>> constructorCalls = type.getConstructors().stream()
|
var constructorCalls = type.getConstructors().stream()
|
||||||
.flatMap(constructor -> constructor.getCallsOfSelf().stream());
|
.flatMap(constructor -> constructor.getCallsOfSelf().stream());
|
||||||
|
|
||||||
this.sources = Stream.concat(constructorCalls, factoryMethodCalls)
|
this.sources = Stream.concat(constructorCalls, factoryMethodCalls)
|
||||||
.filter(call -> !call.getOriginOwner().equals(type))
|
.filter(call -> !call.getOriginOwner().equals(type))
|
||||||
.map(JavaAccessSource::new)
|
.<Source> map(JavaAccessSource::new)
|
||||||
.collect(Collectors.toList());
|
.toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasSources() {
|
public boolean hasSources() {
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ import lombok.RequiredArgsConstructor;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
@@ -56,7 +55,7 @@ public abstract class NamedInterface implements Iterable<JavaClass> {
|
|||||||
|
|
||||||
return Arrays.stream(name) //
|
return Arrays.stream(name) //
|
||||||
.map(it -> new PackageBasedNamedInterface(it, javaPackage)) //
|
.map(it -> new PackageBasedNamedInterface(it, javaPackage)) //
|
||||||
.collect(Collectors.toList());
|
.toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TypeBasedNamedInterface of(String name, Classes classes, JavaPackage basePackage) {
|
public static TypeBasedNamedInterface of(String name, Classes classes, JavaPackage basePackage) {
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ public class NamedInterfaces implements Iterable<NamedInterface> {
|
|||||||
|
|
||||||
return mappings.entrySet().stream() //
|
return mappings.entrySet().stream() //
|
||||||
.map(entry -> NamedInterface.of(entry.getKey(), Classes.of(entry.getValue()), basePackage)) //
|
.map(entry -> NamedInterface.of(entry.getKey(), Classes.of(entry.getValue()), basePackage)) //
|
||||||
.collect(Collectors.toList());
|
.toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
private NamedInterfaces and(NamedInterface namedInterface) {
|
private NamedInterfaces and(NamedInterface namedInterface) {
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ import lombok.Getter;
|
|||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import com.tngtech.archunit.core.domain.JavaClass;
|
import com.tngtech.archunit.core.domain.JavaClass;
|
||||||
|
|
||||||
@@ -65,7 +64,7 @@ public class SpringBean {
|
|||||||
|
|
||||||
return type.getRawInterfaces().stream() //
|
return type.getRawInterfaces().stream() //
|
||||||
.filter(module::contains) //
|
.filter(module::contains) //
|
||||||
.collect(Collectors.toList());
|
.toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAnnotatedWith(Class<?> type) {
|
public boolean isAnnotatedWith(Class<?> type) {
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ class ConfigurationProperties implements Iterable<ConfigurationProperty> {
|
|||||||
|
|
||||||
this.properties = Arrays.stream(resources)
|
this.properties = Arrays.stream(resources)
|
||||||
.flatMap(ConfigurationProperties::parseProperties)
|
.flatMap(ConfigurationProperties::parseProperties)
|
||||||
.collect(Collectors.toList());
|
.toList();
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
@@ -81,7 +81,7 @@ class ConfigurationProperties implements Iterable<ConfigurationProperty> {
|
|||||||
|
|
||||||
return properties.stream()
|
return properties.stream()
|
||||||
.flatMap(it -> getModuleProperty(module, it))
|
.flatMap(it -> getModuleProperty(module, it))
|
||||||
.collect(Collectors.toList());
|
.toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -822,7 +822,7 @@ public class Documenter {
|
|||||||
.filter(it -> !hideInternals || it.isApiBean())
|
.filter(it -> !hideInternals || it.isApiBean())
|
||||||
.filter(it -> !alreadyMapped.contains(it))
|
.filter(it -> !alreadyMapped.contains(it))
|
||||||
.filter(filter::matches)
|
.filter(filter::matches)
|
||||||
.collect(Collectors.toList());
|
.toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Value(staticConstructor = "of")
|
@Value(staticConstructor = "of")
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ import java.util.Collection;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import org.springframework.beans.factory.SmartInitializingSingleton;
|
import org.springframework.beans.factory.SmartInitializingSingleton;
|
||||||
@@ -165,7 +164,7 @@ public class PersistentApplicationEventMulticaster extends AbstractApplicationEv
|
|||||||
.filter(TransactionalApplicationListener.class::isInstance)
|
.filter(TransactionalApplicationListener.class::isInstance)
|
||||||
.map(TransactionalApplicationListener.class::cast)
|
.map(TransactionalApplicationListener.class::cast)
|
||||||
.sorted(AnnotationAwareOrderComparator.INSTANCE)
|
.sorted(AnnotationAwareOrderComparator.INSTANCE)
|
||||||
.collect(Collectors.toList());
|
.toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
private TransactionalEventListeners(
|
private TransactionalEventListeners(
|
||||||
@@ -185,7 +184,7 @@ public class PersistentApplicationEventMulticaster extends AbstractApplicationEv
|
|||||||
|
|
||||||
List<TransactionalApplicationListener<ApplicationEvent>> collect = listeners.stream()
|
List<TransactionalApplicationListener<ApplicationEvent>> collect = listeners.stream()
|
||||||
.filter(it -> it.getTransactionPhase().equals(phase))
|
.filter(it -> it.getTransactionPhase().equals(phase))
|
||||||
.collect(Collectors.toList());
|
.toList();
|
||||||
|
|
||||||
return new TransactionalEventListeners(collect);
|
return new TransactionalEventListeners(collect);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ import lombok.RequiredArgsConstructor;
|
|||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import org.springframework.data.domain.Sort;
|
import org.springframework.data.domain.Sort;
|
||||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||||
@@ -85,16 +84,15 @@ class MongoDbEventPublicationRepository implements EventPublicationRepository {
|
|||||||
var query = query(where("completionDate").isNull());
|
var query = query(where("completionDate").isNull());
|
||||||
|
|
||||||
return mongoTemplate.find(query, MongoDbEventPublication.class).stream() //
|
return mongoTemplate.find(query, MongoDbEventPublication.class).stream() //
|
||||||
.map(this::documentToDomain) //
|
.<EventPublication> map(this::documentToDomain) //
|
||||||
.collect(Collectors.toList());
|
.toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<EventPublication> findIncompletePublicationsByEventAndTargetIdentifier(
|
public Optional<EventPublication> findIncompletePublicationsByEventAndTargetIdentifier(
|
||||||
Object event, PublicationTargetIdentifier targetIdentifier) {
|
Object event, PublicationTargetIdentifier targetIdentifier) {
|
||||||
|
|
||||||
var documents = findDocumentsByEventAndTargetIdentifierAndCompletionDateNull( //
|
var documents = findDocumentsByEventAndTargetIdentifierAndCompletionDateNull(event, targetIdentifier);
|
||||||
event, targetIdentifier);
|
|
||||||
var results = documents
|
var results = documents
|
||||||
.stream() //
|
.stream() //
|
||||||
.map(this::documentToDomain) //
|
.map(this::documentToDomain) //
|
||||||
@@ -113,7 +111,8 @@ class MongoDbEventPublicationRepository implements EventPublicationRepository {
|
|||||||
Object event, PublicationTargetIdentifier targetIdentifier) {
|
Object event, PublicationTargetIdentifier targetIdentifier) {
|
||||||
|
|
||||||
// we need to enforce writing of the type information
|
// we need to enforce writing of the type information
|
||||||
var eventAsMongoType = mongoTemplate.getConverter().convertToMongoType(event, TypeInformation.of(Object.class));
|
var eventAsMongoType = mongoTemplate.getConverter().convertToMongoType(event, TypeInformation.OBJECT);
|
||||||
|
|
||||||
var query = query(
|
var query = query(
|
||||||
where("event").is(eventAsMongoType) //
|
where("event").is(eventAsMongoType) //
|
||||||
.and("listenerId").is(targetIdentifier.getValue()) //
|
.and("listenerId").is(targetIdentifier.getValue()) //
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ class ModulesIntegrationTest {
|
|||||||
|
|
||||||
assertThat(fromPackage.stream().map(ApplicationModule::getName)) //
|
assertThat(fromPackage.stream().map(ApplicationModule::getName)) //
|
||||||
.containsExactlyInAnyOrderElementsOf(
|
.containsExactlyInAnyOrderElementsOf(
|
||||||
modules.stream().map(ApplicationModule::getName).collect(Collectors.toList()));
|
modules.stream().map(ApplicationModule::getName).toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void verifyNamedInterfaces(NamedInterfaces interfaces, String name, Class<?>... types) {
|
private static void verifyNamedInterfaces(NamedInterfaces interfaces, String name, Class<?>... types) {
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ public class MomentsProperties {
|
|||||||
|
|
||||||
return new ShiftedQuarters(Arrays.stream(Quarter.values())
|
return new ShiftedQuarters(Arrays.stream(Quarter.values())
|
||||||
.map(it -> ShiftedQuarter.of(it, shift))
|
.map(it -> ShiftedQuarter.of(it, shift))
|
||||||
.collect(Collectors.toList()));
|
.toList());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ class DefaultPublishedEvents implements PublishedEvents, ApplicationListener<App
|
|||||||
private final List<T> events;
|
private final List<T> events;
|
||||||
|
|
||||||
private static <T> SimpleTypedPublishedEvents<T> of(Stream<T> stream) {
|
private static <T> SimpleTypedPublishedEvents<T> of(Stream<T> stream) {
|
||||||
return new SimpleTypedPublishedEvents<>(stream.collect(Collectors.toList()));
|
return new SimpleTypedPublishedEvents<>(stream.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ class ModuleTestAutoConfiguration {
|
|||||||
public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
|
public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
|
||||||
|
|
||||||
ModuleTestExecution execution = ((BeanFactory) registry).getBean(ModuleTestExecution.class);
|
ModuleTestExecution execution = ((BeanFactory) registry).getBean(ModuleTestExecution.class);
|
||||||
List<String> basePackages = execution.getBasePackages().collect(Collectors.toList());
|
List<String> basePackages = execution.getBasePackages().toList();
|
||||||
|
|
||||||
LOG.info("Re-configuring auto-configuration and entity scan packages to: {}.",
|
LOG.info("Re-configuring auto-configuration and entity scan packages to: {}.",
|
||||||
StringUtils.collectionToDelimitedString(basePackages, ", "));
|
StringUtils.collectionToDelimitedString(basePackages, ", "));
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ public class ModuleTestExecution implements Iterable<ApplicationModule> {
|
|||||||
this.bootstrapMode = annotation.mode();
|
this.bootstrapMode = annotation.mode();
|
||||||
this.module = module;
|
this.module = module;
|
||||||
|
|
||||||
this.extraIncludes = getExtraModules(annotation, modules).collect(Collectors.toList());
|
this.extraIncludes = getExtraModules(annotation, modules).toList();
|
||||||
|
|
||||||
this.basePackages = Suppliers.memoize(() -> {
|
this.basePackages = Suppliers.memoize(() -> {
|
||||||
|
|
||||||
@@ -78,13 +78,13 @@ public class ModuleTestExecution implements Iterable<ApplicationModule> {
|
|||||||
|
|
||||||
Stream<JavaPackage> intermediate = Stream.concat(moduleBasePackages, extraPackages);
|
Stream<JavaPackage> intermediate = Stream.concat(moduleBasePackages, extraPackages);
|
||||||
|
|
||||||
return Stream.concat(intermediate, sharedBasePackages).distinct().collect(Collectors.toList());
|
return Stream.concat(intermediate, sharedBasePackages).distinct().toList();
|
||||||
});
|
});
|
||||||
|
|
||||||
this.dependencies = Suppliers.memoize(() -> {
|
this.dependencies = Suppliers.memoize(() -> {
|
||||||
|
|
||||||
Stream<ApplicationModule> bootstrapDependencies = module.getBootstrapDependencies(modules, bootstrapMode.getDepth());
|
Stream<ApplicationModule> bootstrapDependencies = module.getBootstrapDependencies(modules, bootstrapMode.getDepth());
|
||||||
return Stream.concat(bootstrapDependencies, extraIncludes.stream()).collect(Collectors.toList());
|
return Stream.concat(bootstrapDependencies, extraIncludes.stream()).toList();
|
||||||
});
|
});
|
||||||
|
|
||||||
if (annotation.verifyAutomatically()) {
|
if (annotation.verifyAutomatically()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user