Convert some Functions/Predicates to streams & lambdas (3)

Change-Id: I04f7aa685352941b2f29975ec42c58f5c5f70822
This commit is contained in:
Dave Borowitz
2016-09-20 10:11:30 -04:00
parent d3848b15a3
commit d39fb04d3f
13 changed files with 103 additions and 207 deletions

View File

@@ -15,14 +15,12 @@
package com.google.gerrit.server; package com.google.gerrit.server;
import static java.nio.charset.StandardCharsets.UTF_8; import static java.nio.charset.StandardCharsets.UTF_8;
import static java.util.stream.Collectors.toSet;
import com.google.auto.value.AutoValue; import com.google.auto.value.AutoValue;
import com.google.common.base.CharMatcher; import com.google.common.base.CharMatcher;
import com.google.common.base.Function;
import com.google.common.base.Joiner; import com.google.common.base.Joiner;
import com.google.common.base.Predicate;
import com.google.common.base.Splitter; import com.google.common.base.Splitter;
import com.google.common.collect.FluentIterable;
import com.google.common.collect.ImmutableMultimap; import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSortedSet; import com.google.common.collect.ImmutableSortedSet;
@@ -249,29 +247,11 @@ public class StarredChangesUtil {
public Set<Account.Id> byChange(final Change.Id changeId, public Set<Account.Id> byChange(final Change.Id changeId,
final String label) throws OrmException { final String label) throws OrmException {
try (final Repository repo = repoManager.openRepository(allUsers)) { try (final Repository repo = repoManager.openRepository(allUsers)) {
return FluentIterable return getRefNames(repo, RefNames.refsStarredChangesPrefix(changeId))
.from(getRefNames(repo, RefNames.refsStarredChangesPrefix(changeId))) .stream()
.transform(new Function<String, Account.Id>() { .map(Account.Id::parse)
@Override .filter(accountId -> hasStar(repo, changeId, accountId, label))
public Account.Id apply(String refPart) { .collect(toSet());
return Account.Id.parse(refPart);
}
})
.filter(new Predicate<Account.Id>() {
@Override
public boolean apply(Account.Id accountId) {
try {
return readLabels(repo,
RefNames.refsStarredChanges(changeId, accountId))
.contains(label);
} catch (IOException e) {
log.error(String.format(
"Cannot query stars by account %d on change %d",
accountId.get(), changeId.get()), e);
return false;
}
}
}).toSet();
} catch (IOException e) { } catch (IOException e) {
throw new OrmException( throw new OrmException(
String.format("Get accounts that starred change %d failed", String.format("Get accounts that starred change %d failed",
@@ -283,36 +263,12 @@ public class StarredChangesUtil {
// To be used only for IsStarredByLegacyPredicate. // To be used only for IsStarredByLegacyPredicate.
public Set<Change.Id> byAccount(final Account.Id accountId, public Set<Change.Id> byAccount(final Account.Id accountId,
final String label) throws OrmException { final String label) throws OrmException {
try (final Repository repo = repoManager.openRepository(allUsers)) { try (Repository repo = repoManager.openRepository(allUsers)) {
return FluentIterable return getRefNames(repo, RefNames.REFS_STARRED_CHANGES).stream()
.from(getRefNames(repo, RefNames.REFS_STARRED_CHANGES)) .filter(refPart -> refPart.endsWith("/" + accountId.get()))
.filter(new Predicate<String>() { .map(Change.Id::fromRefPart)
@Override .filter(changeId -> hasStar(repo, changeId, accountId, label))
public boolean apply(String refPart) { .collect(toSet());
return refPart.endsWith("/" + accountId.get());
}
})
.transform(new Function<String, Change.Id>() {
@Override
public Change.Id apply(String refPart) {
return Change.Id.fromRefPart(refPart);
}
})
.filter(new Predicate<Change.Id>() {
@Override
public boolean apply(Change.Id changeId) {
try {
return readLabels(repo,
RefNames.refsStarredChanges(changeId, accountId))
.contains(label);
} catch (IOException e) {
log.error(String.format(
"Cannot query stars by account %d on change %d",
accountId.get(), changeId.get()), e);
return false;
}
}
}).toSet();
} catch (IOException e) { } catch (IOException e) {
throw new OrmException( throw new OrmException(
String.format("Get changes that were starred by %d failed", String.format("Get changes that were starred by %d failed",
@@ -320,6 +276,20 @@ public class StarredChangesUtil {
} }
} }
private boolean hasStar(Repository repo, Change.Id changeId,
Account.Id accountId, String label) {
try {
return readLabels(repo,
RefNames.refsStarredChanges(changeId, accountId))
.contains(label);
} catch (IOException e) {
log.error(String.format(
"Cannot query stars by account %d on change %d",
accountId.get(), changeId.get()), e);
return false;
}
}
public ImmutableMultimap<Account.Id, String> byChangeFromIndex( public ImmutableMultimap<Account.Id, String> byChangeFromIndex(
Change.Id changeId) throws OrmException, NoSuchChangeException { Change.Id changeId) throws OrmException, NoSuchChangeException {
Set<String> fields = ImmutableSet.of( Set<String> fields = ImmutableSet.of(

View File

@@ -15,11 +15,10 @@
package com.google.gerrit.server.events; package com.google.gerrit.server.events;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import static java.util.Comparator.comparing;
import com.google.common.base.Function;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Multimap; import com.google.common.collect.Multimap;
import com.google.common.collect.Ordering;
import com.google.gerrit.common.Nullable; import com.google.gerrit.common.Nullable;
import com.google.gerrit.common.data.LabelType; import com.google.gerrit.common.data.LabelType;
import com.google.gerrit.common.data.LabelTypes; import com.google.gerrit.common.data.LabelTypes;
@@ -64,14 +63,6 @@ import com.google.gwtorm.server.SchemaFactory;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.Provider; import com.google.inject.Provider;
import com.google.inject.Singleton; import com.google.inject.Singleton;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.PersonIdent;
import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.jgit.revwalk.RevWalk;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException; import java.io.IOException;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.ArrayList; import java.util.ArrayList;
@@ -80,6 +71,12 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.PersonIdent;
import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.jgit.revwalk.RevWalk;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Singleton @Singleton
public class EventFactory { public class EventFactory {
@@ -298,22 +295,21 @@ public class EventFactory {
} }
} }
// Sort by original parent order. // Sort by original parent order.
Collections.sort(ca.dependsOn, Ordering.natural().onResultOf( Collections.sort(
new Function<DependencyAttribute, Integer>() { ca.dependsOn,
@Override comparing(
public Integer apply(DependencyAttribute d) { (DependencyAttribute d) -> {
for (int i = 0; i < parentNames.size(); i++) { for (int i = 0; i < parentNames.size(); i++) {
if (parentNames.get(i).equals(d.revision)) { if (parentNames.get(i).equals(d.revision)) {
return i; return i;
}
} }
} return parentNames.size() + 1;
return parentNames.size() + 1; }));
}
}));
} }
private void addNeededBy(RevWalk rw, ChangeAttribute ca, Change change, private void addNeededBy(RevWalk rw, ChangeAttribute ca, Change change, PatchSet currentPs)
PatchSet currentPs) throws OrmException, IOException { throws OrmException, IOException {
if (currentPs.getGroups().isEmpty()) { if (currentPs.getGroups().isEmpty()) {
return; return;
} }

View File

@@ -16,7 +16,6 @@ package com.google.gerrit.server.git;
import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkArgument;
import com.google.common.base.Function;
import com.google.common.collect.Ordering; import com.google.common.collect.Ordering;
import com.google.gerrit.reviewdb.client.Change; import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.PatchSet; import com.google.gerrit.reviewdb.client.PatchSet;
@@ -46,14 +45,11 @@ public class CodeReviewCommit extends RevCommit {
* AnyObjectId} and only orders on SHA-1. * AnyObjectId} and only orders on SHA-1.
*/ */
public static final Ordering<CodeReviewCommit> ORDER = Ordering.natural() public static final Ordering<CodeReviewCommit> ORDER = Ordering.natural()
.onResultOf(new Function<CodeReviewCommit, Integer>() { .onResultOf((CodeReviewCommit c) ->
@Override c.getPatchsetId() != null
public Integer apply(CodeReviewCommit in) { ? c.getPatchsetId().getParentKey().get()
return in.getPatchsetId() != null : null)
? in.getPatchsetId().getParentKey().get() .nullsFirst();
: null;
}
}).nullsFirst();
public static CodeReviewRevWalk newRevWalk(Repository repo) { public static CodeReviewRevWalk newRevWalk(Repository repo) {
return new CodeReviewRevWalk(repo); return new CodeReviewRevWalk(repo);

View File

@@ -18,7 +18,6 @@ import static com.google.common.base.Preconditions.checkState;
import static org.eclipse.jgit.revwalk.RevFlag.UNINTERESTING; import static org.eclipse.jgit.revwalk.RevFlag.UNINTERESTING;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Function;
import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.HashMultimap; import com.google.common.collect.HashMultimap;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
@@ -158,13 +157,7 @@ public class GroupCollector {
private static Multimap<ObjectId, PatchSet.Id> transformRefs( private static Multimap<ObjectId, PatchSet.Id> transformRefs(
Multimap<ObjectId, Ref> refs) { Multimap<ObjectId, Ref> refs) {
return Multimaps.transformValues( return Multimaps.transformValues(
refs, refs, r -> PatchSet.Id.fromRef(r.getName()));
new Function<Ref, PatchSet.Id>() {
@Override
public PatchSet.Id apply(Ref in) {
return PatchSet.Id.fromRef(in.getName());
}
});
} }
@VisibleForTesting @VisibleForTesting

View File

@@ -17,12 +17,11 @@ package com.google.gerrit.server.git;
import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState; import static com.google.common.base.Preconditions.checkState;
import static java.util.Comparator.comparing;
import com.google.auto.value.AutoValue; import com.google.auto.value.AutoValue;
import com.google.common.base.Function;
import com.google.common.base.Joiner; import com.google.common.base.Joiner;
import com.google.common.base.Optional; import com.google.common.base.Optional;
import com.google.common.base.Predicate;
import com.google.common.collect.HashMultimap; import com.google.common.collect.HashMultimap;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMultimap; import com.google.common.collect.ImmutableMultimap;
@@ -31,7 +30,6 @@ import com.google.common.collect.ImmutableSetMultimap;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.google.common.collect.Multimap; import com.google.common.collect.Multimap;
import com.google.common.collect.MultimapBuilder; import com.google.common.collect.MultimapBuilder;
import com.google.common.collect.Ordering;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import com.google.gerrit.common.Nullable; import com.google.gerrit.common.Nullable;
import com.google.gerrit.common.TimeUtil; import com.google.gerrit.common.TimeUtil;
@@ -122,13 +120,10 @@ public class MergeOp implements AutoCloseable {
} }
byBranch = bb.build(); byBranch = bb.build();
commits = new HashMap<>(); commits = new HashMap<>();
problems = MultimapBuilder.treeKeys( problems = MultimapBuilder
Ordering.natural().onResultOf(new Function<Change.Id, Integer>() { .treeKeys(comparing(Change.Id::get))
@Override .arrayListValues(1)
public Integer apply(Change.Id in) { .build();
return in.get();
}
})).arrayListValues(1).build();
} }
public ImmutableSet<Change.Id> getChangeIds() { public ImmutableSet<Change.Id> getChangeIds() {
@@ -264,12 +259,7 @@ public class MergeOp implements AutoCloseable {
if (in == null) { if (in == null) {
return Optional.absent(); return Optional.absent();
} }
return Iterables.tryFind(in, new Predicate<SubmitRecord>() { return Iterables.tryFind(in, r -> r.status == SubmitRecord.Status.OK);
@Override
public boolean apply(SubmitRecord input) {
return input.status == SubmitRecord.Status.OK;
}
});
} }
public static void checkSubmitRule(ChangeData cd) public static void checkSubmitRule(ChangeData cd)

View File

@@ -16,9 +16,9 @@ package com.google.gerrit.server.git;
import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkArgument;
import com.google.common.base.Function;
import com.google.common.base.Joiner; import com.google.common.base.Joiner;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import com.google.common.collect.FluentIterable;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
@@ -599,14 +599,10 @@ public class MergeUtil {
Joiner.on("', '").join(topics)); Joiner.on("', '").join(topics));
} else { } else {
return String.format("Merge changes %s%s", return String.format("Merge changes %s%s",
Joiner.on(',').join(Iterables.transform( FluentIterable.from(merged)
Iterables.limit(merged, 5), .limit(5)
new Function<CodeReviewCommit, String>() { .transform(c -> c.change().getKey().abbreviate())
@Override .join(Joiner.on(',')),
public String apply(CodeReviewCommit in) {
return in.change().getKey().abbreviate();
}
})),
merged.size() > 5 ? ", ..." : ""); merged.size() > 5 ? ", ..." : "");
} }
} }

View File

@@ -14,8 +14,8 @@
package com.google.gerrit.server.git; package com.google.gerrit.server.git;
import com.google.common.base.Predicate; import static java.util.stream.Collectors.toList;
import com.google.common.collect.FluentIterable;
import com.google.gerrit.reviewdb.client.Project; import com.google.gerrit.reviewdb.client.Project;
import org.eclipse.jgit.lib.Ref; import org.eclipse.jgit.lib.Ref;
@@ -45,12 +45,7 @@ class TagSetHolder {
} }
TagMatcher matcher(TagCache cache, Repository db, Collection<Ref> include) { TagMatcher matcher(TagCache cache, Repository db, Collection<Ref> include) {
include = FluentIterable.from(include).filter(new Predicate<Ref>() { include = include.stream().filter(r -> !TagSet.skip(r)).collect(toList());
@Override
public boolean apply(Ref ref) {
return !TagSet.skip(ref);
}
}).toList();
TagSet tags = this.tags; TagSet tags = this.tags;
if (tags == null) { if (tags == null) {

View File

@@ -14,7 +14,6 @@
package com.google.gerrit.server.git.strategy; package com.google.gerrit.server.git.strategy;
import com.google.common.base.Function;
import com.google.common.collect.FluentIterable; import com.google.common.collect.FluentIterable;
import com.google.gerrit.extensions.client.SubmitType; import com.google.gerrit.extensions.client.SubmitType;
import com.google.gerrit.reviewdb.client.Branch; import com.google.gerrit.reviewdb.client.Branch;
@@ -70,12 +69,7 @@ public class SubmitDryRun {
return FluentIterable return FluentIterable
.from(repo.getRefDatabase().getRefs(Constants.R_HEADS).values()) .from(repo.getRefDatabase().getRefs(Constants.R_HEADS).values())
.append(repo.getRefDatabase().getRefs(Constants.R_TAGS).values()) .append(repo.getRefDatabase().getRefs(Constants.R_TAGS).values())
.transform(new Function<Ref, ObjectId>() { .transform(Ref::getObjectId);
@Override
public ObjectId apply(Ref r) {
return r.getObjectId();
}
});
} }
public static Set<RevCommit> getAlreadyAccepted(Repository repo, RevWalk rw) public static Set<RevCommit> getAlreadyAccepted(Repository repo, RevWalk rw)

View File

@@ -50,15 +50,6 @@ import com.google.gerrit.server.git.SubmoduleException;
import com.google.gerrit.server.notedb.ChangeUpdate; import com.google.gerrit.server.notedb.ChangeUpdate;
import com.google.gerrit.server.project.ProjectState; import com.google.gerrit.server.project.ProjectState;
import com.google.gwtorm.server.OrmException; import com.google.gwtorm.server.OrmException;
import org.eclipse.jgit.errors.IncorrectObjectTypeException;
import org.eclipse.jgit.errors.MissingObjectException;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.transport.ReceiveCommand;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
@@ -67,6 +58,13 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
import org.eclipse.jgit.errors.IncorrectObjectTypeException;
import org.eclipse.jgit.errors.MissingObjectException;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.transport.ReceiveCommand;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
abstract class SubmitStrategyOp extends BatchUpdate.Op { abstract class SubmitStrategyOp extends BatchUpdate.Op {
private static final Logger log = private static final Logger log =
@@ -379,14 +377,11 @@ abstract class SubmitStrategyOp extends BatchUpdate.Op {
private static Function<PatchSetApproval, PatchSetApproval> private static Function<PatchSetApproval, PatchSetApproval>
convertPatchSet(final PatchSet.Id psId) { convertPatchSet(final PatchSet.Id psId) {
return new Function<PatchSetApproval, PatchSetApproval>() { return psa -> {
@Override if (psa.getPatchSetId().equals(psId)) {
public PatchSetApproval apply(PatchSetApproval in) { return psa;
if (in.getPatchSetId().equals(psId)) {
return in;
}
return new PatchSetApproval(psId, in);
} }
return new PatchSetApproval(psId, psa);
}; };
} }
@@ -397,14 +392,12 @@ abstract class SubmitStrategyOp extends BatchUpdate.Op {
private static Iterable<PatchSetApproval> zero( private static Iterable<PatchSetApproval> zero(
Iterable<PatchSetApproval> approvals) { Iterable<PatchSetApproval> approvals) {
return Iterables.transform(approvals, return Iterables.transform(
new Function<PatchSetApproval, PatchSetApproval>() { approvals,
@Override a -> {
public PatchSetApproval apply(PatchSetApproval in) { PatchSetApproval copy = new PatchSetApproval(a.getPatchSetId(), a);
PatchSetApproval copy = new PatchSetApproval(in.getPatchSetId(), in); copy.setValue((short) 0);
copy.setValue((short) 0); return copy;
return copy;
}
}); });
} }

View File

@@ -17,7 +17,6 @@ package com.google.gerrit.server.plugins;
import static com.google.common.base.MoreObjects.firstNonNull; import static com.google.common.base.MoreObjects.firstNonNull;
import static com.google.common.collect.Iterables.transform; import static com.google.common.collect.Iterables.transform;
import com.google.common.base.Function;
import com.google.common.base.Optional; import com.google.common.base.Optional;
import com.google.common.base.Predicates; import com.google.common.base.Predicates;
import com.google.common.base.Strings; import com.google.common.base.Strings;
@@ -59,15 +58,6 @@ import java.util.jar.Manifest;
public class JarScanner implements PluginContentScanner { public class JarScanner implements PluginContentScanner {
private static final int SKIP_ALL = ClassReader.SKIP_CODE private static final int SKIP_ALL = ClassReader.SKIP_CODE
| ClassReader.SKIP_DEBUG | ClassReader.SKIP_FRAMES; | ClassReader.SKIP_DEBUG | ClassReader.SKIP_FRAMES;
private static final Function<ClassData, ExtensionMetaData> CLASS_DATA_TO_EXTENSION_META_DATA =
new Function<ClassData, ExtensionMetaData>() {
@Override
public ExtensionMetaData apply(ClassData classData) {
return new ExtensionMetaData(classData.className,
classData.annotationValue);
}
};
private final JarFile jarFile; private final JarFile jarFile;
public JarScanner(Path src) throws IOException { public JarScanner(Path src) throws IOException {
@@ -128,8 +118,11 @@ public class JarScanner implements PluginContentScanner {
Collection<ClassData> values = Collection<ClassData> values =
firstNonNull(discoverdData, Collections.<ClassData> emptySet()); firstNonNull(discoverdData, Collections.<ClassData> emptySet());
result.put(annotoation, result.put(
transform(values, CLASS_DATA_TO_EXTENSION_META_DATA)); annotoation,
transform(
values,
cd -> new ExtensionMetaData(cd.className, cd.annotationValue)));
} }
return result.build(); return result.build();
@@ -307,15 +300,12 @@ public class JarScanner implements PluginContentScanner {
public Enumeration<PluginEntry> entries() { public Enumeration<PluginEntry> entries() {
return Collections.enumeration(Lists.transform( return Collections.enumeration(Lists.transform(
Collections.list(jarFile.entries()), Collections.list(jarFile.entries()),
new Function<JarEntry, PluginEntry>() { jarEntry -> {
@Override try {
public PluginEntry apply(JarEntry jarEntry) { return resourceOf(jarEntry);
try { } catch (IOException e) {
return resourceOf(jarEntry); throw new IllegalArgumentException("Cannot convert jar entry "
} catch (IOException e) { + jarEntry + " to a resource", e);
throw new IllegalArgumentException("Cannot convert jar entry "
+ jarEntry + " to a resource", e);
}
} }
})); }));
} }

View File

@@ -14,11 +14,10 @@
package com.google.gerrit.server.plugins; package com.google.gerrit.server.plugins;
import com.google.common.base.Function; import static java.util.stream.Collectors.joining;
import com.google.common.base.Joiner;
import com.google.common.collect.Iterables;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.stream.StreamSupport;
class MultipleProvidersForPluginException extends IllegalArgumentException { class MultipleProvidersForPluginException extends IllegalArgumentException {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@@ -32,14 +31,8 @@ class MultipleProvidersForPluginException extends IllegalArgumentException {
private static String providersListToString( private static String providersListToString(
Iterable<ServerPluginProvider> providersHandlers) { Iterable<ServerPluginProvider> providersHandlers) {
Iterable<String> providerNames = return StreamSupport.stream(providersHandlers.spliterator(), false)
Iterables.transform(providersHandlers, .map(ServerPluginProvider::getProviderPluginName)
new Function<ServerPluginProvider, String>() { .collect(joining(", "));
@Override
public String apply(ServerPluginProvider provider) {
return provider.getProviderPluginName();
}
});
return Joiner.on(", ").join(providerNames);
} }
} }

View File

@@ -17,7 +17,6 @@ package com.google.gerrit.server.plugins;
import com.google.common.base.CharMatcher; import com.google.common.base.CharMatcher;
import com.google.common.base.Joiner; import com.google.common.base.Joiner;
import com.google.common.base.MoreObjects; import com.google.common.base.MoreObjects;
import com.google.common.base.Predicate;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import com.google.common.collect.ComparisonChain; import com.google.common.collect.ComparisonChain;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
@@ -720,12 +719,9 @@ public class PluginLoader implements LifecycleListener {
private static Iterable<Path> filterDisabledPlugins( private static Iterable<Path> filterDisabledPlugins(
Collection<Path> paths) { Collection<Path> paths) {
return Iterables.filter(paths, new Predicate<Path>() { return Iterables.filter(
@Override paths,
public boolean apply(Path p) { p -> !p.getFileName().toString().endsWith(".disabled"));
return !p.getFileName().toString().endsWith(".disabled");
}
});
} }
public String getGerritPluginName(Path srcPath) { public String getGerritPluginName(Path srcPath) {

View File

@@ -17,7 +17,6 @@ package com.google.gerrit.server.util;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.base.Function; import com.google.common.base.Function;
import com.google.common.base.Predicate;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
@@ -94,12 +93,7 @@ public abstract class RegexListSearcher<T> implements Function<T, String> {
return Iterables.filter( return Iterables.filter(
list.subList(begin, end), list.subList(begin, end),
new Predicate<T>() { x -> pattern.run(apply(x)));
@Override
public boolean apply(T in) {
return pattern.run(RegexListSearcher.this.apply(in));
}
});
} }
public boolean hasMatch(List<T> list) { public boolean hasMatch(List<T> list) {