]> source.dussan.org Git - jgit.git/commitdiff
GC: Replace anonymous classes with lambdas 85/116785/1
authorHector Caballero <hector.caballero@ericsson.com>
Tue, 30 Jan 2018 01:57:50 +0000 (20:57 -0500)
committerHector Caballero <hector.caballero@ericsson.com>
Tue, 6 Feb 2018 11:29:29 +0000 (06:29 -0500)
Signed-off-by: Hector Oswaldo Caballero <hector.caballero@ericsson.com>
Change-Id: Ic9725bdb1a281c80055a5438a02d961b1d1875f4

org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java

index 75b0f0b25b783889eac0c3849bd273778c18c241..b74d927b63f93d434080118a57d5d395fb8a31ed 100644 (file)
@@ -65,7 +65,6 @@ import java.time.temporal.ChronoUnit;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
-import java.util.Comparator;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -1099,23 +1098,21 @@ public class GC {
                        throws IOException {
                checkCancelled();
                File tmpPack = null;
-               Map<PackExt, File> tmpExts = new TreeMap<>(
-                               new Comparator<PackExt>() {
-                                       @Override
-                                       public int compare(PackExt o1, PackExt o2) {
-                                               // INDEX entries must be returned last, so the pack
-                                               // scanner does pick up the new pack until all the
-                                               // PackExt entries have been written.
-                                               if (o1 == o2)
-                                                       return 0;
-                                               if (o1 == PackExt.INDEX)
-                                                       return 1;
-                                               if (o2 == PackExt.INDEX)
-                                                       return -1;
-                                               return Integer.signum(o1.hashCode() - o2.hashCode());
-                                       }
-
-                               });
+               Map<PackExt, File> tmpExts = new TreeMap<>((o1, o2) -> {
+                       // INDEX entries must be returned last, so the pack
+                       // scanner does pick up the new pack until all the
+                       // PackExt entries have been written.
+                       if (o1 == o2) {
+                               return 0;
+                       }
+                       if (o1 == PackExt.INDEX) {
+                               return 1;
+                       }
+                       if (o2 == PackExt.INDEX) {
+                               return -1;
+                       }
+                       return Integer.signum(o1.hashCode() - o2.hashCode());
+               });
                try (PackWriter pw = new PackWriter(
                                (pconfig == null) ? new PackConfig(repo) : pconfig,
                                repo.newObjectReader())) {
@@ -1531,19 +1528,14 @@ public class GC {
                if (!Files.exists(dir)) {
                        return false;
                }
-               try (DirectoryStream<Path> stream = Files.newDirectoryStream(dir,
-                               new DirectoryStream.Filter<Path>() {
-
-                                       @Override
-                                       public boolean accept(Path file) throws IOException {
-                                               Path fileName = file.getFileName();
-                                               return Files.isRegularFile(file) && fileName != null
-                                                               && PATTERN_LOOSE_OBJECT
-                                                                               .matcher(fileName.toString()).matches();
-                                       }
+               try (DirectoryStream<Path> stream = Files.newDirectoryStream(dir, file -> {
+                                       Path fileName = file.getFileName();
+                                       return Files.isRegularFile(file) && fileName != null
+                                                       && PATTERN_LOOSE_OBJECT.matcher(fileName.toString())
+                                                                       .matches();
                                })) {
-                       for (Iterator<Path> iter = stream.iterator(); iter.hasNext();
-                                       iter.next()) {
+                       for (Iterator<Path> iter = stream.iterator(); iter.hasNext(); iter
+                                       .next()) {
                                if (++n > threshold) {
                                        return true;
                                }