Convert some Functions/Predicates to streams & lambdas (3)
Change-Id: I04f7aa685352941b2f29975ec42c58f5c5f70822
This commit is contained in:
		| @@ -15,14 +15,12 @@ | ||||
| package com.google.gerrit.server; | ||||
|  | ||||
| import static java.nio.charset.StandardCharsets.UTF_8; | ||||
| import static java.util.stream.Collectors.toSet; | ||||
|  | ||||
| import com.google.auto.value.AutoValue; | ||||
| import com.google.common.base.CharMatcher; | ||||
| import com.google.common.base.Function; | ||||
| import com.google.common.base.Joiner; | ||||
| import com.google.common.base.Predicate; | ||||
| import com.google.common.base.Splitter; | ||||
| import com.google.common.collect.FluentIterable; | ||||
| import com.google.common.collect.ImmutableMultimap; | ||||
| import com.google.common.collect.ImmutableSet; | ||||
| import com.google.common.collect.ImmutableSortedSet; | ||||
| @@ -249,29 +247,11 @@ public class StarredChangesUtil { | ||||
|   public Set<Account.Id> byChange(final Change.Id changeId, | ||||
|       final String label) throws OrmException { | ||||
|     try (final Repository repo = repoManager.openRepository(allUsers)) { | ||||
|       return FluentIterable | ||||
|           .from(getRefNames(repo, RefNames.refsStarredChangesPrefix(changeId))) | ||||
|           .transform(new Function<String, Account.Id>() { | ||||
|             @Override | ||||
|             public Account.Id apply(String refPart) { | ||||
|               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(); | ||||
|       return getRefNames(repo, RefNames.refsStarredChangesPrefix(changeId)) | ||||
|           .stream() | ||||
|           .map(Account.Id::parse) | ||||
|           .filter(accountId -> hasStar(repo, changeId, accountId, label)) | ||||
|           .collect(toSet()); | ||||
|     } catch (IOException e) { | ||||
|       throw new OrmException( | ||||
|           String.format("Get accounts that starred change %d failed", | ||||
| @@ -283,36 +263,12 @@ public class StarredChangesUtil { | ||||
|   // To be used only for IsStarredByLegacyPredicate. | ||||
|   public Set<Change.Id> byAccount(final Account.Id accountId, | ||||
|       final String label) throws OrmException { | ||||
|     try (final Repository repo = repoManager.openRepository(allUsers)) { | ||||
|       return FluentIterable | ||||
|           .from(getRefNames(repo, RefNames.REFS_STARRED_CHANGES)) | ||||
|           .filter(new Predicate<String>() { | ||||
|             @Override | ||||
|             public boolean apply(String refPart) { | ||||
|               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(); | ||||
|     try (Repository repo = repoManager.openRepository(allUsers)) { | ||||
|       return getRefNames(repo, RefNames.REFS_STARRED_CHANGES).stream() | ||||
|           .filter(refPart -> refPart.endsWith("/" + accountId.get())) | ||||
|           .map(Change.Id::fromRefPart) | ||||
|           .filter(changeId -> hasStar(repo, changeId, accountId, label)) | ||||
|           .collect(toSet()); | ||||
|     } catch (IOException e) { | ||||
|       throw new OrmException( | ||||
|           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( | ||||
|       Change.Id changeId) throws OrmException, NoSuchChangeException { | ||||
|     Set<String> fields = ImmutableSet.of( | ||||
|   | ||||
| @@ -15,11 +15,10 @@ | ||||
| package com.google.gerrit.server.events; | ||||
|  | ||||
| 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.Multimap; | ||||
| import com.google.common.collect.Ordering; | ||||
| import com.google.gerrit.common.Nullable; | ||||
| import com.google.gerrit.common.data.LabelType; | ||||
| 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.Provider; | ||||
| 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.sql.Timestamp; | ||||
| import java.util.ArrayList; | ||||
| @@ -80,6 +71,12 @@ import java.util.Collections; | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
| 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 | ||||
| public class EventFactory { | ||||
| @@ -298,22 +295,21 @@ public class EventFactory { | ||||
|       } | ||||
|     } | ||||
|     // Sort by original parent order. | ||||
|     Collections.sort(ca.dependsOn, Ordering.natural().onResultOf( | ||||
|         new Function<DependencyAttribute, Integer>() { | ||||
|           @Override | ||||
|           public Integer apply(DependencyAttribute d) { | ||||
|             for (int i = 0; i < parentNames.size(); i++) { | ||||
|               if (parentNames.get(i).equals(d.revision)) { | ||||
|                 return i; | ||||
|     Collections.sort( | ||||
|         ca.dependsOn, | ||||
|         comparing( | ||||
|             (DependencyAttribute d) -> { | ||||
|               for (int i = 0; i < parentNames.size(); i++) { | ||||
|                 if (parentNames.get(i).equals(d.revision)) { | ||||
|                   return i; | ||||
|                 } | ||||
|               } | ||||
|             } | ||||
|             return parentNames.size() + 1; | ||||
|           } | ||||
|         })); | ||||
|               return parentNames.size() + 1; | ||||
|             })); | ||||
|   } | ||||
|  | ||||
|   private void addNeededBy(RevWalk rw, ChangeAttribute ca, Change change, | ||||
|       PatchSet currentPs) throws OrmException, IOException { | ||||
|   private void addNeededBy(RevWalk rw, ChangeAttribute ca, Change change, PatchSet currentPs) | ||||
|       throws OrmException, IOException { | ||||
|     if (currentPs.getGroups().isEmpty()) { | ||||
|       return; | ||||
|     } | ||||
|   | ||||
| @@ -16,7 +16,6 @@ package com.google.gerrit.server.git; | ||||
|  | ||||
| import static com.google.common.base.Preconditions.checkArgument; | ||||
|  | ||||
| import com.google.common.base.Function; | ||||
| import com.google.common.collect.Ordering; | ||||
| import com.google.gerrit.reviewdb.client.Change; | ||||
| import com.google.gerrit.reviewdb.client.PatchSet; | ||||
| @@ -46,14 +45,11 @@ public class CodeReviewCommit extends RevCommit { | ||||
|    * AnyObjectId} and only orders on SHA-1. | ||||
|    */ | ||||
|   public static final Ordering<CodeReviewCommit> ORDER = Ordering.natural() | ||||
|       .onResultOf(new Function<CodeReviewCommit, Integer>() { | ||||
|         @Override | ||||
|         public Integer apply(CodeReviewCommit in) { | ||||
|           return in.getPatchsetId() != null | ||||
|               ? in.getPatchsetId().getParentKey().get() | ||||
|               : null; | ||||
|         } | ||||
|       }).nullsFirst(); | ||||
|       .onResultOf((CodeReviewCommit c) -> | ||||
|           c.getPatchsetId() != null | ||||
|               ? c.getPatchsetId().getParentKey().get() | ||||
|               : null) | ||||
|       .nullsFirst(); | ||||
|  | ||||
|   public static CodeReviewRevWalk newRevWalk(Repository repo) { | ||||
|     return new CodeReviewRevWalk(repo); | ||||
|   | ||||
| @@ -18,7 +18,6 @@ import static com.google.common.base.Preconditions.checkState; | ||||
| import static org.eclipse.jgit.revwalk.RevFlag.UNINTERESTING; | ||||
|  | ||||
| import com.google.common.annotations.VisibleForTesting; | ||||
| import com.google.common.base.Function; | ||||
| import com.google.common.collect.ArrayListMultimap; | ||||
| import com.google.common.collect.HashMultimap; | ||||
| import com.google.common.collect.ImmutableList; | ||||
| @@ -158,13 +157,7 @@ public class GroupCollector { | ||||
|   private static Multimap<ObjectId, PatchSet.Id> transformRefs( | ||||
|       Multimap<ObjectId, Ref> refs) { | ||||
|     return Multimaps.transformValues( | ||||
|         refs, | ||||
|         new Function<Ref, PatchSet.Id>() { | ||||
|           @Override | ||||
|           public PatchSet.Id apply(Ref in) { | ||||
|             return PatchSet.Id.fromRef(in.getName()); | ||||
|           } | ||||
|         }); | ||||
|         refs, r -> PatchSet.Id.fromRef(r.getName())); | ||||
|   } | ||||
|  | ||||
|   @VisibleForTesting | ||||
|   | ||||
| @@ -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.checkNotNull; | ||||
| import static com.google.common.base.Preconditions.checkState; | ||||
| import static java.util.Comparator.comparing; | ||||
|  | ||||
| import com.google.auto.value.AutoValue; | ||||
| import com.google.common.base.Function; | ||||
| import com.google.common.base.Joiner; | ||||
| import com.google.common.base.Optional; | ||||
| import com.google.common.base.Predicate; | ||||
| import com.google.common.collect.HashMultimap; | ||||
| import com.google.common.collect.ImmutableMap; | ||||
| 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.Multimap; | ||||
| import com.google.common.collect.MultimapBuilder; | ||||
| import com.google.common.collect.Ordering; | ||||
| import com.google.common.collect.Sets; | ||||
| import com.google.gerrit.common.Nullable; | ||||
| import com.google.gerrit.common.TimeUtil; | ||||
| @@ -122,13 +120,10 @@ public class MergeOp implements AutoCloseable { | ||||
|       } | ||||
|       byBranch = bb.build(); | ||||
|       commits = new HashMap<>(); | ||||
|       problems = MultimapBuilder.treeKeys( | ||||
|           Ordering.natural().onResultOf(new Function<Change.Id, Integer>() { | ||||
|             @Override | ||||
|             public Integer apply(Change.Id in) { | ||||
|               return in.get(); | ||||
|             } | ||||
|           })).arrayListValues(1).build(); | ||||
|       problems = MultimapBuilder | ||||
|           .treeKeys(comparing(Change.Id::get)) | ||||
|           .arrayListValues(1) | ||||
|           .build(); | ||||
|     } | ||||
|  | ||||
|     public ImmutableSet<Change.Id> getChangeIds() { | ||||
| @@ -264,12 +259,7 @@ public class MergeOp implements AutoCloseable { | ||||
|     if (in == null) { | ||||
|       return Optional.absent(); | ||||
|     } | ||||
|     return Iterables.tryFind(in, new Predicate<SubmitRecord>() { | ||||
|       @Override | ||||
|       public boolean apply(SubmitRecord input) { | ||||
|         return input.status == SubmitRecord.Status.OK; | ||||
|       } | ||||
|     }); | ||||
|     return Iterables.tryFind(in, r -> r.status == SubmitRecord.Status.OK); | ||||
|   } | ||||
|  | ||||
|   public static void checkSubmitRule(ChangeData cd) | ||||
|   | ||||
| @@ -16,9 +16,9 @@ package com.google.gerrit.server.git; | ||||
|  | ||||
| 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.Strings; | ||||
| import com.google.common.collect.FluentIterable; | ||||
| import com.google.common.collect.ImmutableList; | ||||
| import com.google.common.collect.Iterables; | ||||
| import com.google.common.collect.Sets; | ||||
| @@ -599,14 +599,10 @@ public class MergeUtil { | ||||
|           Joiner.on("', '").join(topics)); | ||||
|     } else { | ||||
|       return String.format("Merge changes %s%s", | ||||
|           Joiner.on(',').join(Iterables.transform( | ||||
|               Iterables.limit(merged, 5), | ||||
|               new Function<CodeReviewCommit, String>() { | ||||
|                 @Override | ||||
|                 public String apply(CodeReviewCommit in) { | ||||
|                   return in.change().getKey().abbreviate(); | ||||
|                 } | ||||
|               })), | ||||
|           FluentIterable.from(merged) | ||||
|               .limit(5) | ||||
|               .transform(c -> c.change().getKey().abbreviate()) | ||||
|               .join(Joiner.on(',')), | ||||
|           merged.size() > 5 ? ", ..." : ""); | ||||
|     } | ||||
|   } | ||||
|   | ||||
| @@ -14,8 +14,8 @@ | ||||
|  | ||||
| package com.google.gerrit.server.git; | ||||
|  | ||||
| import com.google.common.base.Predicate; | ||||
| import com.google.common.collect.FluentIterable; | ||||
| import static java.util.stream.Collectors.toList; | ||||
|  | ||||
| import com.google.gerrit.reviewdb.client.Project; | ||||
|  | ||||
| import org.eclipse.jgit.lib.Ref; | ||||
| @@ -45,12 +45,7 @@ class TagSetHolder { | ||||
|   } | ||||
|  | ||||
|   TagMatcher matcher(TagCache cache, Repository db, Collection<Ref> include) { | ||||
|     include = FluentIterable.from(include).filter(new Predicate<Ref>() { | ||||
|       @Override | ||||
|       public boolean apply(Ref ref) { | ||||
|         return !TagSet.skip(ref); | ||||
|       } | ||||
|     }).toList(); | ||||
|     include = include.stream().filter(r -> !TagSet.skip(r)).collect(toList()); | ||||
|  | ||||
|     TagSet tags = this.tags; | ||||
|     if (tags == null) { | ||||
|   | ||||
| @@ -14,7 +14,6 @@ | ||||
|  | ||||
| package com.google.gerrit.server.git.strategy; | ||||
|  | ||||
| import com.google.common.base.Function; | ||||
| import com.google.common.collect.FluentIterable; | ||||
| import com.google.gerrit.extensions.client.SubmitType; | ||||
| import com.google.gerrit.reviewdb.client.Branch; | ||||
| @@ -70,12 +69,7 @@ public class SubmitDryRun { | ||||
|     return FluentIterable | ||||
|         .from(repo.getRefDatabase().getRefs(Constants.R_HEADS).values()) | ||||
|         .append(repo.getRefDatabase().getRefs(Constants.R_TAGS).values()) | ||||
|         .transform(new Function<Ref, ObjectId>() { | ||||
|           @Override | ||||
|           public ObjectId apply(Ref r) { | ||||
|             return r.getObjectId(); | ||||
|           } | ||||
|         }); | ||||
|         .transform(Ref::getObjectId); | ||||
|   } | ||||
|  | ||||
|   public static Set<RevCommit> getAlreadyAccepted(Repository repo, RevWalk rw) | ||||
|   | ||||
| @@ -50,15 +50,6 @@ import com.google.gerrit.server.git.SubmoduleException; | ||||
| import com.google.gerrit.server.notedb.ChangeUpdate; | ||||
| import com.google.gerrit.server.project.ProjectState; | ||||
| 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.util.ArrayList; | ||||
| import java.util.Collection; | ||||
| @@ -67,6 +58,13 @@ import java.util.HashMap; | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
| 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 { | ||||
|   private static final Logger log = | ||||
| @@ -379,14 +377,11 @@ abstract class SubmitStrategyOp extends BatchUpdate.Op { | ||||
|  | ||||
|   private static Function<PatchSetApproval, PatchSetApproval> | ||||
|       convertPatchSet(final PatchSet.Id psId) { | ||||
|     return new Function<PatchSetApproval, PatchSetApproval>() { | ||||
|       @Override | ||||
|       public PatchSetApproval apply(PatchSetApproval in) { | ||||
|         if (in.getPatchSetId().equals(psId)) { | ||||
|           return in; | ||||
|         } | ||||
|         return new PatchSetApproval(psId, in); | ||||
|     return psa -> { | ||||
|       if (psa.getPatchSetId().equals(psId)) { | ||||
|         return psa; | ||||
|       } | ||||
|       return new PatchSetApproval(psId, psa); | ||||
|     }; | ||||
|   } | ||||
|  | ||||
| @@ -397,14 +392,12 @@ abstract class SubmitStrategyOp extends BatchUpdate.Op { | ||||
|  | ||||
|   private static Iterable<PatchSetApproval> zero( | ||||
|       Iterable<PatchSetApproval> approvals) { | ||||
|     return Iterables.transform(approvals, | ||||
|         new Function<PatchSetApproval, PatchSetApproval>() { | ||||
|           @Override | ||||
|           public PatchSetApproval apply(PatchSetApproval in) { | ||||
|             PatchSetApproval copy = new PatchSetApproval(in.getPatchSetId(), in); | ||||
|             copy.setValue((short) 0); | ||||
|             return copy; | ||||
|           } | ||||
|     return Iterables.transform( | ||||
|         approvals, | ||||
|         a -> { | ||||
|           PatchSetApproval copy = new PatchSetApproval(a.getPatchSetId(), a); | ||||
|           copy.setValue((short) 0); | ||||
|           return copy; | ||||
|         }); | ||||
|   } | ||||
|  | ||||
|   | ||||
| @@ -17,7 +17,6 @@ package com.google.gerrit.server.plugins; | ||||
| import static com.google.common.base.MoreObjects.firstNonNull; | ||||
| 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.Predicates; | ||||
| import com.google.common.base.Strings; | ||||
| @@ -59,15 +58,6 @@ import java.util.jar.Manifest; | ||||
| public class JarScanner implements PluginContentScanner { | ||||
|   private static final int SKIP_ALL = ClassReader.SKIP_CODE | ||||
|       | 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; | ||||
|  | ||||
|   public JarScanner(Path src) throws IOException { | ||||
| @@ -128,8 +118,11 @@ public class JarScanner implements PluginContentScanner { | ||||
|       Collection<ClassData> values = | ||||
|           firstNonNull(discoverdData, Collections.<ClassData> emptySet()); | ||||
|  | ||||
|       result.put(annotoation, | ||||
|           transform(values, CLASS_DATA_TO_EXTENSION_META_DATA)); | ||||
|       result.put( | ||||
|           annotoation, | ||||
|           transform( | ||||
|               values, | ||||
|               cd -> new ExtensionMetaData(cd.className, cd.annotationValue))); | ||||
|     } | ||||
|  | ||||
|     return result.build(); | ||||
| @@ -307,15 +300,12 @@ public class JarScanner implements PluginContentScanner { | ||||
|   public Enumeration<PluginEntry> entries() { | ||||
|     return Collections.enumeration(Lists.transform( | ||||
|         Collections.list(jarFile.entries()), | ||||
|         new Function<JarEntry, PluginEntry>() { | ||||
|           @Override | ||||
|           public PluginEntry apply(JarEntry jarEntry) { | ||||
|             try { | ||||
|               return resourceOf(jarEntry); | ||||
|             } catch (IOException e) { | ||||
|               throw new IllegalArgumentException("Cannot convert jar entry " | ||||
|                   + jarEntry + " to a resource", e); | ||||
|             } | ||||
|         jarEntry -> { | ||||
|           try { | ||||
|             return resourceOf(jarEntry); | ||||
|           } catch (IOException e) { | ||||
|             throw new IllegalArgumentException("Cannot convert jar entry " | ||||
|                 + jarEntry + " to a resource", e); | ||||
|           } | ||||
|         })); | ||||
|   } | ||||
|   | ||||
| @@ -14,11 +14,10 @@ | ||||
|  | ||||
| package com.google.gerrit.server.plugins; | ||||
|  | ||||
| import com.google.common.base.Function; | ||||
| import com.google.common.base.Joiner; | ||||
| import com.google.common.collect.Iterables; | ||||
| import static java.util.stream.Collectors.joining; | ||||
|  | ||||
| import java.nio.file.Path; | ||||
| import java.util.stream.StreamSupport; | ||||
|  | ||||
| class MultipleProvidersForPluginException extends IllegalArgumentException { | ||||
|   private static final long serialVersionUID = 1L; | ||||
| @@ -32,14 +31,8 @@ class MultipleProvidersForPluginException extends IllegalArgumentException { | ||||
|  | ||||
|   private static String providersListToString( | ||||
|       Iterable<ServerPluginProvider> providersHandlers) { | ||||
|     Iterable<String> providerNames = | ||||
|         Iterables.transform(providersHandlers, | ||||
|             new Function<ServerPluginProvider, String>() { | ||||
|               @Override | ||||
|               public String apply(ServerPluginProvider provider) { | ||||
|                 return provider.getProviderPluginName(); | ||||
|               } | ||||
|             }); | ||||
|     return Joiner.on(", ").join(providerNames); | ||||
|     return StreamSupport.stream(providersHandlers.spliterator(), false) | ||||
|         .map(ServerPluginProvider::getProviderPluginName) | ||||
|         .collect(joining(", ")); | ||||
|   } | ||||
| } | ||||
|   | ||||
| @@ -17,7 +17,6 @@ package com.google.gerrit.server.plugins; | ||||
| import com.google.common.base.CharMatcher; | ||||
| import com.google.common.base.Joiner; | ||||
| import com.google.common.base.MoreObjects; | ||||
| import com.google.common.base.Predicate; | ||||
| import com.google.common.base.Strings; | ||||
| import com.google.common.collect.ComparisonChain; | ||||
| import com.google.common.collect.ImmutableList; | ||||
| @@ -720,12 +719,9 @@ public class PluginLoader implements LifecycleListener { | ||||
|  | ||||
|   private static Iterable<Path> filterDisabledPlugins( | ||||
|       Collection<Path> paths) { | ||||
|     return Iterables.filter(paths, new Predicate<Path>() { | ||||
|       @Override | ||||
|       public boolean apply(Path p) { | ||||
|         return !p.getFileName().toString().endsWith(".disabled"); | ||||
|       } | ||||
|     }); | ||||
|     return Iterables.filter( | ||||
|         paths, | ||||
|         p -> !p.getFileName().toString().endsWith(".disabled")); | ||||
|   } | ||||
|  | ||||
|   public String getGerritPluginName(Path srcPath) { | ||||
|   | ||||
| @@ -17,7 +17,6 @@ package com.google.gerrit.server.util; | ||||
| import static com.google.common.base.Preconditions.checkNotNull; | ||||
|  | ||||
| import com.google.common.base.Function; | ||||
| import com.google.common.base.Predicate; | ||||
| import com.google.common.collect.ImmutableList; | ||||
| import com.google.common.collect.Iterables; | ||||
| import com.google.common.collect.Lists; | ||||
| @@ -94,12 +93,7 @@ public abstract class RegexListSearcher<T> implements Function<T, String> { | ||||
|  | ||||
|     return Iterables.filter( | ||||
|         list.subList(begin, end), | ||||
|         new Predicate<T>() { | ||||
|           @Override | ||||
|           public boolean apply(T in) { | ||||
|             return pattern.run(RegexListSearcher.this.apply(in)); | ||||
|           } | ||||
|         }); | ||||
|         x -> pattern.run(apply(x))); | ||||
|   } | ||||
|  | ||||
|   public boolean hasMatch(List<T> list) { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Dave Borowitz
					Dave Borowitz