Browse Source

Use lambdas where possible

Using the batch cleanup operation via Source -> Cleanup -> "Use lambdas
where possible" from standard JDT.

Change-Id: I5452bd94fdccc920ade071228aeed3a8b9fdbe62
Signed-off-by: Lars Vogel <Lars.Vogel@vogella.com>
stable-5.8
Lars Vogel 5 years ago
parent
commit
9d1e477417
  1. 13
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackFile.java
  2. 19
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java

13
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackFile.java

@ -71,13 +71,12 @@ import org.slf4j.LoggerFactory;
*/ */
public class PackFile implements Iterable<PackIndex.MutableEntry> { public class PackFile implements Iterable<PackIndex.MutableEntry> {
private final static Logger LOG = LoggerFactory.getLogger(PackFile.class); private final static Logger LOG = LoggerFactory.getLogger(PackFile.class);
/** Sorts PackFiles to be most recently created to least recently created. */
public static final Comparator<PackFile> SORT = new Comparator<PackFile>() { /**
@Override * Sorts PackFiles to be most recently created to least recently created.
public int compare(PackFile a, PackFile b) { */
return b.packLastModified.compareTo(a.packLastModified); public static final Comparator<PackFile> SORT = (a, b) -> b.packLastModified
} .compareTo(a.packLastModified);
};
private final File packFile; private final File packFile;

19
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java

@ -142,23 +142,24 @@ public class PackWriter implements AutoCloseable {
private static final Map<WeakReference<PackWriter>, Boolean> instances = private static final Map<WeakReference<PackWriter>, Boolean> instances =
new ConcurrentHashMap<>(); new ConcurrentHashMap<>();
private static final Iterable<PackWriter> instancesIterable = new Iterable<PackWriter>() { private static final Iterable<PackWriter> instancesIterable = () -> new Iterator<PackWriter>() {
@Override
public Iterator<PackWriter> iterator() { private final Iterator<WeakReference<PackWriter>> it = instances
return new Iterator<PackWriter>() { .keySet().iterator();
private final Iterator<WeakReference<PackWriter>> it =
instances.keySet().iterator();
private PackWriter next; private PackWriter next;
@Override @Override
public boolean hasNext() { public boolean hasNext() {
if (next != null) if (next != null) {
return true; return true;
}
while (it.hasNext()) { while (it.hasNext()) {
WeakReference<PackWriter> ref = it.next(); WeakReference<PackWriter> ref = it.next();
next = ref.get(); next = ref.get();
if (next != null) if (next != null) {
return true; return true;
}
it.remove(); it.remove();
} }
return false; return false;
@ -179,8 +180,6 @@ public class PackWriter implements AutoCloseable {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
}; };
}
};
/** /**
* Get all allocated, non-released PackWriters instances. * Get all allocated, non-released PackWriters instances.

Loading…
Cancel
Save