refactor: replace StreamSupport.stream(spliterator, false) with Guava's Stream.stream(iterable)

This commit is contained in:
broDom
2017-07-05 21:02:17 +02:00
parent d7b539ba10
commit 1da3c7436c
4 changed files with 19 additions and 20 deletions

View File

@@ -33,8 +33,8 @@ package sonia.scm.repository.api;
//~--- non-JDK imports --------------------------------------------------------
import com.google.common.base.Function;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Streams;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import sonia.scm.io.DeepCopy;
@@ -46,8 +46,8 @@ import sonia.scm.repository.spi.HookChangesetRequest;
import java.io.IOException;
import java.util.List;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
//~--- JDK imports ------------------------------------------------------------
@@ -135,9 +135,9 @@ public final class HookChangesetBuilder
return copy;
};
changesets = StreamSupport.stream(changesets.spliterator(), false)
.map(changesetFunction::apply)
.collect(Collectors.toList());
changesets = Streams.stream(changesets)
.map(changesetFunction::apply)
.collect(Collectors.toList());
}
return changesets;

View File

@@ -34,12 +34,12 @@
package sonia.scm.util;
import com.google.common.base.Splitter;
import com.google.common.collect.Streams;
import sonia.scm.Validateable;
import java.util.Arrays;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.StreamSupport;
/**
*
@@ -134,9 +134,9 @@ public final class ValidationUtil
* @return
*/
public static boolean isRepositoryNameValid(String name) {
return Util.isNotEmpty(name) && StreamSupport.stream(Splitter.on('/').split(name).spliterator(), false)
.map(REPO_NAME_REGEX::matcher)
.allMatch(Matcher::matches);
return Util.isNotEmpty(name) && Streams.stream(Splitter.on('/').split(name))
.map(REPO_NAME_REGEX::matcher)
.allMatch(Matcher::matches);
}
/**

View File

@@ -38,6 +38,7 @@ package sonia.scm.web;
import com.google.common.base.Function;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterables;
import com.google.common.collect.Streams;
import com.google.common.io.Closeables;
import com.google.inject.Inject;
import org.slf4j.Logger;
@@ -62,7 +63,6 @@ import java.io.Writer;
import java.util.Date;
import java.util.Iterator;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
//~--- JDK imports ------------------------------------------------------------
@@ -301,11 +301,10 @@ public class GitRepositoryViewer
.setBranch(name)
.setPagingLimit(CHANGESET_PER_BRANCH)
.getChangesets();
Iterable<ChangesetModel> changesets =
StreamSupport.stream(cpr.spliterator(), false)
.map(ChangesetModel::new)
.collect(Collectors.toList());
Iterable<ChangesetModel> changesets = Streams.stream(cpr)
.map(ChangesetModel::new)
.collect(Collectors.toList());
//J+
model = new BranchModel(name, changesets);

View File

@@ -35,6 +35,7 @@ package sonia.scm.plugin;
import com.google.common.base.Charsets;
import com.google.common.collect.Iterables;
import com.google.common.collect.Streams;
import com.google.common.io.Resources;
import org.junit.Before;
import org.junit.Rule;
@@ -48,7 +49,6 @@ import java.io.OutputStream;
import java.lang.reflect.InvocationTargetException;
import java.net.URL;
import java.util.Set;
import java.util.stream.StreamSupport;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.is;
@@ -366,10 +366,10 @@ public class PluginProcessorTest
private PluginWrapper findPlugin(Iterable<PluginWrapper> plugin,
final String id)
{
return StreamSupport.stream(plugin.spliterator(), false)
.filter(input -> id.equals(input.getId()))
.findFirst()
.orElse(null);
return Streams.stream(plugin)
.filter(input -> id.equals(input.getId()))
.findFirst()
.orElse(null);
}
//~--- inner classes --------------------------------------------------------