mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-07-20 09:51:08 +02:00
refactor: replace StreamSupport.stream(spliterator, false) with Guava's Stream.stream(iterable)
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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 --------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user