#136 - Replace Streamable with the one from Spring Data Commons.
This commit is contained in:
@@ -33,6 +33,11 @@
|
||||
<artifactId>spring-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-commons</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<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 org.springframework.data.release.Streamable;
|
||||
import org.springframework.data.release.model.Project;
|
||||
import org.springframework.data.release.model.ProjectAware;
|
||||
import org.springframework.data.release.utils.ListWrapperCollector;
|
||||
import org.springframework.data.release.utils.Logger;
|
||||
import org.springframework.data.util.Streamable;
|
||||
import org.springframework.plugin.core.PluginRegistry;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
@@ -15,23 +15,23 @@
|
||||
*/
|
||||
package org.springframework.data.release.git;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.data.release.Streamable;
|
||||
import org.springframework.data.release.issues.Ticket;
|
||||
import org.springframework.data.util.Streamable;
|
||||
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.
|
||||
*
|
||||
*
|
||||
* @author Mark Paluch
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
@@ -44,7 +44,7 @@ public class TicketBranches implements Streamable<Branch> {
|
||||
/**
|
||||
* Returns whether there's a ticket available for the given {@link Branch}. If {@code requireResolved} is set to
|
||||
* {@literal true} the answer will only be true if the available ticket is marked resolved.
|
||||
*
|
||||
*
|
||||
* @param branch must not be {@literal null}.
|
||||
* @param requireResolved whether the {@link Ticket} we look for is required to be resolved.
|
||||
* @return
|
||||
@@ -60,7 +60,7 @@ public class TicketBranches implements Streamable<Branch> {
|
||||
|
||||
/**
|
||||
* Returns a {@link TicketBranches} containing only the branches for which resolved {@link Ticket}s are found.
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public TicketBranches getResolvedTickets() {
|
||||
@@ -72,7 +72,7 @@ public class TicketBranches implements Streamable<Branch> {
|
||||
|
||||
/**
|
||||
* Returns the ticket for the given {@link Branch}.
|
||||
*
|
||||
*
|
||||
* @param branch must not be {@literal null}.
|
||||
* @return
|
||||
*/
|
||||
|
||||
@@ -21,14 +21,14 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.data.release.Streamable;
|
||||
import org.springframework.data.release.model.ArtifactVersion;
|
||||
import org.springframework.data.release.model.ModuleIteration;
|
||||
import org.springframework.data.util.Streamable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Value object to represent a collection of {@link Tag}s.
|
||||
*
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
@EqualsAndHashCode
|
||||
@@ -38,7 +38,7 @@ public class VersionTags implements Streamable<Tag> {
|
||||
|
||||
/**
|
||||
* Creates a new {@link VersionTags} instance for the given {@link List} of {@link Tag}s.
|
||||
*
|
||||
*
|
||||
* @param source must not be {@literal null}.
|
||||
*/
|
||||
VersionTags(List<Tag> source) {
|
||||
@@ -52,7 +52,7 @@ public class VersionTags implements Streamable<Tag> {
|
||||
|
||||
/**
|
||||
* Returns the latest {@link Tag}.
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Tag getLatest() {
|
||||
@@ -65,14 +65,14 @@ public class VersionTags implements Streamable<Tag> {
|
||||
|
||||
/**
|
||||
* Returns all {@link Tag}s as {@link List}.
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public List<Tag> asList() {
|
||||
return tags;
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see java.lang.Iterable#iterator()
|
||||
*/
|
||||
|
||||
@@ -25,10 +25,10 @@ import java.util.Optional;
|
||||
import java.util.stream.Collector;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.springframework.data.release.Streamable;
|
||||
import org.springframework.data.release.model.ModuleIteration;
|
||||
import org.springframework.data.release.model.TrainIteration;
|
||||
import org.springframework.data.release.utils.ListWrapperCollector;
|
||||
import org.springframework.data.util.Streamable;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
|
||||
@@ -22,7 +22,7 @@ import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.release.Streamable;
|
||||
import org.springframework.data.util.Streamable;
|
||||
|
||||
/**
|
||||
* @author Oliver Gierke
|
||||
@@ -46,7 +46,7 @@ class JiraIssues implements Streamable<JiraIssue> {
|
||||
return !issues.isEmpty();
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see java.lang.Iterable#iterator()
|
||||
*/
|
||||
|
||||
@@ -21,11 +21,11 @@ import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.release.Streamable;
|
||||
import org.springframework.data.util.Streamable;
|
||||
|
||||
/**
|
||||
* Value object to bind REST responses to.
|
||||
*
|
||||
*
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@Value
|
||||
|
||||
@@ -19,12 +19,12 @@ import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
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
|
||||
* {@link Module} instances.
|
||||
*
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
class Modules implements Streamable<Module> {
|
||||
|
||||
@@ -62,7 +62,8 @@ public class ReleaseTrains {
|
||||
new Module(MONGO_DB, "3.0"), //
|
||||
new Module(JDBC, "2.0"), //
|
||||
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
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ import java.util.stream.Stream;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
import org.springframework.data.release.Streamable;
|
||||
import org.springframework.data.util.Streamable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -115,7 +115,7 @@ public class Train implements Streamable<Module> {
|
||||
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()));
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ import lombok.Value;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.release.Streamable;
|
||||
import org.springframework.data.util.Streamable;
|
||||
|
||||
/**
|
||||
* @author Oliver Gierke
|
||||
|
||||
@@ -23,12 +23,12 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.data.release.Streamable;
|
||||
import org.springframework.data.release.model.ArtifactVersion;
|
||||
import org.springframework.data.util.Streamable;
|
||||
|
||||
/**
|
||||
* Wrapper type for a {@link List} of {@link MaintainedVersion}.
|
||||
*
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
@ToString
|
||||
@@ -40,7 +40,7 @@ class MaintainedVersions implements Streamable<MaintainedVersion> {
|
||||
/**
|
||||
* Creates a new {@link MaintainedVersions} with the given {@link MaintainedVersion}s in descending order (more recent
|
||||
* versions first).
|
||||
*
|
||||
*
|
||||
* @param versions must not be {@literal null}.
|
||||
* @return
|
||||
*/
|
||||
@@ -54,7 +54,7 @@ class MaintainedVersions implements Streamable<MaintainedVersion> {
|
||||
/**
|
||||
* Creates a new {@link MaintainedVersions} with the given {@link MaintainedVersion}s in descending order (more recent
|
||||
* versions first).
|
||||
*
|
||||
*
|
||||
* @param versions must not be {@literal null}.
|
||||
* @return
|
||||
*/
|
||||
@@ -64,7 +64,7 @@ class MaintainedVersions implements Streamable<MaintainedVersion> {
|
||||
|
||||
/**
|
||||
* Returns whether the given {@link MaintainedVersion} is the main version of the current set.
|
||||
*
|
||||
*
|
||||
* @param version must not be {@literal null}.
|
||||
* @return
|
||||
*/
|
||||
@@ -82,7 +82,7 @@ class MaintainedVersions implements Streamable<MaintainedVersion> {
|
||||
.orElse(false);
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see java.lang.Iterable#iterator()
|
||||
*/
|
||||
|
||||
@@ -24,7 +24,7 @@ import java.util.function.Function;
|
||||
import java.util.stream.Collector;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.data.release.Streamable;
|
||||
import org.springframework.data.util.Streamable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -75,7 +75,7 @@ public class ExecutionUtils {
|
||||
Collector<? super S, ?, R> collector) {
|
||||
|
||||
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().//
|
||||
map(it -> CompletableFuture.supplyAsync(() -> function.apply(it))).//
|
||||
|
||||
Reference in New Issue
Block a user