#136 - Replace Streamable with the one from Spring Data Commons.
This commit is contained in:
@@ -33,6 +33,11 @@
|
|||||||
<artifactId>spring-web</artifactId>
|
<artifactId>spring-web</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.data</groupId>
|
||||||
|
<artifactId>spring-data-commons</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
<artifactId>jackson-databind</artifactId>
|
<artifactId>jackson-databind</artifactId>
|
||||||
|
|||||||
@@ -1,36 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2016 the original author or authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.springframework.data.release;
|
|
||||||
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
import java.util.stream.StreamSupport;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* SImple interface to ease streamability of {@link Iterable}s.
|
|
||||||
*
|
|
||||||
* @author Oliver Gierke
|
|
||||||
*/
|
|
||||||
public interface Streamable<T> extends Iterable<T> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a non-parallel {@link Stream} of the underlying {@link Iterable}.
|
|
||||||
*
|
|
||||||
* @return will never be {@literal null}.
|
|
||||||
*/
|
|
||||||
public default Stream<T> stream() {
|
|
||||||
return StreamSupport.stream(spliterator(), false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -39,11 +39,11 @@ import java.util.stream.Collector;
|
|||||||
|
|
||||||
import javax.annotation.PreDestroy;
|
import javax.annotation.PreDestroy;
|
||||||
|
|
||||||
import org.springframework.data.release.Streamable;
|
|
||||||
import org.springframework.data.release.model.Project;
|
import org.springframework.data.release.model.Project;
|
||||||
import org.springframework.data.release.model.ProjectAware;
|
import org.springframework.data.release.model.ProjectAware;
|
||||||
import org.springframework.data.release.utils.ListWrapperCollector;
|
import org.springframework.data.release.utils.ListWrapperCollector;
|
||||||
import org.springframework.data.release.utils.Logger;
|
import org.springframework.data.release.utils.Logger;
|
||||||
|
import org.springframework.data.util.Streamable;
|
||||||
import org.springframework.plugin.core.PluginRegistry;
|
import org.springframework.plugin.core.PluginRegistry;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|||||||
@@ -15,20 +15,20 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.release.git;
|
package org.springframework.data.release.git;
|
||||||
|
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NonNull;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.springframework.data.release.Streamable;
|
|
||||||
import org.springframework.data.release.issues.Ticket;
|
import org.springframework.data.release.issues.Ticket;
|
||||||
|
import org.springframework.data.util.Streamable;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.NonNull;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Value object to represent a collection of {@link Branch}es with assigned tickets.
|
* Value object to represent a collection of {@link Branch}es with assigned tickets.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -21,9 +21,9 @@ import java.util.Iterator;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.springframework.data.release.Streamable;
|
|
||||||
import org.springframework.data.release.model.ArtifactVersion;
|
import org.springframework.data.release.model.ArtifactVersion;
|
||||||
import org.springframework.data.release.model.ModuleIteration;
|
import org.springframework.data.release.model.ModuleIteration;
|
||||||
|
import org.springframework.data.util.Streamable;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -25,10 +25,10 @@ import java.util.Optional;
|
|||||||
import java.util.stream.Collector;
|
import java.util.stream.Collector;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import org.springframework.data.release.Streamable;
|
|
||||||
import org.springframework.data.release.model.ModuleIteration;
|
import org.springframework.data.release.model.ModuleIteration;
|
||||||
import org.springframework.data.release.model.TrainIteration;
|
import org.springframework.data.release.model.TrainIteration;
|
||||||
import org.springframework.data.release.utils.ListWrapperCollector;
|
import org.springframework.data.release.utils.ListWrapperCollector;
|
||||||
|
import org.springframework.data.util.Streamable;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.springframework.data.release.Streamable;
|
import org.springframework.data.util.Streamable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Oliver Gierke
|
* @author Oliver Gierke
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.springframework.data.release.Streamable;
|
import org.springframework.data.util.Streamable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Value object to bind REST responses to.
|
* Value object to bind REST responses to.
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import java.util.Collection;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
|
|
||||||
import org.springframework.data.release.Streamable;
|
import org.springframework.data.util.Streamable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A {@link Streamable} set of modules. Makes sure the stream order will match the natural dependency order of the given
|
* A {@link Streamable} set of modules. Makes sure the stream order will match the natural dependency order of the given
|
||||||
|
|||||||
@@ -62,7 +62,8 @@ public class ReleaseTrains {
|
|||||||
new Module(MONGO_DB, "3.0"), //
|
new Module(MONGO_DB, "3.0"), //
|
||||||
new Module(JDBC, "2.0"), //
|
new Module(JDBC, "2.0"), //
|
||||||
new Module(R2DBC, "1.1")) //
|
new Module(R2DBC, "1.1")) //
|
||||||
.filter(module -> !module.getProject().equals(GEMFIRE)).withIterations(new Train.Iterations(M1, M2, M3, RC1, GA));
|
.filterModules(module -> !module.getProject().equals(GEMFIRE))
|
||||||
|
.withIterations(new Train.Iterations(M1, M2, M3, M4, RC1, GA));
|
||||||
|
|
||||||
// Trains
|
// Trains
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ import java.util.stream.Stream;
|
|||||||
|
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
|
|
||||||
import org.springframework.data.release.Streamable;
|
import org.springframework.data.util.Streamable;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -115,7 +115,7 @@ public class Train implements Streamable<Module> {
|
|||||||
return new Train(name, collect);
|
return new Train(name, collect);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Train filter(Predicate<Module> filterPredicate) {
|
public Train filterModules(Predicate<Module> filterPredicate) {
|
||||||
return new Train(name, getModules().stream().filter(filterPredicate).collect(Collectors.toList()));
|
return new Train(name, getModules().stream().filter(filterPredicate).collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import lombok.Value;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.springframework.data.release.Streamable;
|
import org.springframework.data.util.Streamable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Oliver Gierke
|
* @author Oliver Gierke
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ import java.util.Iterator;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.springframework.data.release.Streamable;
|
|
||||||
import org.springframework.data.release.model.ArtifactVersion;
|
import org.springframework.data.release.model.ArtifactVersion;
|
||||||
|
import org.springframework.data.util.Streamable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrapper type for a {@link List} of {@link MaintainedVersion}.
|
* Wrapper type for a {@link List} of {@link MaintainedVersion}.
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import java.util.function.Function;
|
|||||||
import java.util.stream.Collector;
|
import java.util.stream.Collector;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.springframework.data.release.Streamable;
|
import org.springframework.data.util.Streamable;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -75,7 +75,7 @@ public class ExecutionUtils {
|
|||||||
Collector<? super S, ?, R> collector) {
|
Collector<? super S, ?, R> collector) {
|
||||||
|
|
||||||
Assert.notNull(streamable, "Iterable must not be null!");
|
Assert.notNull(streamable, "Iterable must not be null!");
|
||||||
Assert.notNull(function, "Consumer must not be null!");
|
Assert.notNull(function, "Function must not be null!");
|
||||||
|
|
||||||
return streamable.stream().//
|
return streamable.stream().//
|
||||||
map(it -> CompletableFuture.supplyAsync(() -> function.apply(it))).//
|
map(it -> CompletableFuture.supplyAsync(() -> function.apply(it))).//
|
||||||
|
|||||||
Reference in New Issue
Block a user