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> {
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
public int compare(PackFile a, PackFile b) {
return b.packLastModified.compareTo(a.packLastModified);
}
};
/**
* Sorts PackFiles to be most recently created to least recently created.
*/
public static final Comparator<PackFile> SORT = (a, b) -> b.packLastModified
.compareTo(a.packLastModified);
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 =
new ConcurrentHashMap<>();
private static final Iterable<PackWriter> instancesIterable = new Iterable<PackWriter>() {
@Override
public Iterator<PackWriter> iterator() {
return new Iterator<PackWriter>() {
private final Iterator<WeakReference<PackWriter>> it =
instances.keySet().iterator();
private static final Iterable<PackWriter> instancesIterable = () -> new Iterator<PackWriter>() {
private final Iterator<WeakReference<PackWriter>> it = instances
.keySet().iterator();
private PackWriter next;
@Override
public boolean hasNext() {
if (next != null)
if (next != null) {
return true;
}
while (it.hasNext()) {
WeakReference<PackWriter> ref = it.next();
next = ref.get();
if (next != null)
if (next != null) {
return true;
}
it.remove();
}
return false;
@ -179,8 +180,6 @@ public class PackWriter implements AutoCloseable {
throw new UnsupportedOperationException();
}
};
}
};
/**
* Get all allocated, non-released PackWriters instances.

Loading…
Cancel
Save