aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit
diff options
context:
space:
mode:
authorIvan Frade <ifrade@google.com>2023-11-16 15:12:47 -0800
committerIvan Frade <ifrade@google.com>2023-11-16 16:05:14 -0800
commite612c2522862433c9892627aaa528f34c067349e (patch)
treea1f4900a0b6695b8ce8dc2bf0fa3cf79cf95c301 /org.eclipse.jgit
parent4d82d0aa1f45e8bdf09c1a4990a7edb2a29a3a4d (diff)
downloadjgit-e612c2522862433c9892627aaa528f34c067349e.tar.gz
jgit-e612c2522862433c9892627aaa528f34c067349e.zip
BitmapWalkListener: Use plain interface with noop instance
In this new interface default methods are useful only to instantiate noop instances. We rather reuse the same noop instance and save the "default" to add backward compatible methods to existing interfaces. Make the methods regular interface methods and provide a noop instance. Change-Id: Ie84ff17c8e9f16837245751739ee8c99463e76ee
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/revwalk/BitmapWalker.java42
1 files changed, 28 insertions, 14 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/BitmapWalker.java b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/BitmapWalker.java
index 2218462426..c0e41d644a 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/BitmapWalker.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/BitmapWalker.java
@@ -54,14 +54,13 @@ public final class BitmapWalker {
*/
public interface BitmapWalkListener {
/**
- * The commit is already in the walk bitmap
+ * The commit was already visited or is reachable from a visited commit
*
* @param oid
- * objectId of the commit already in bitmap
+ * objectId of the commit already visited directly or
+ * indirectly
*/
- default void onCommitInBitmap(ObjectId oid) {
- // Nothing to do
- }
+ void onCommitSeen(ObjectId oid);
/**
* The commit has a bitmap in the bitmap index
@@ -69,9 +68,7 @@ public final class BitmapWalker {
* @param oid
* objectId of the commit with a bitmap in the bitmap index
*/
- default void onCommitWithBitmap(ObjectId oid) {
- // Nothing to do
- }
+ void onCommitWithBitmap(ObjectId oid);
/**
* The commit doesn't have bitmap
@@ -80,13 +77,30 @@ public final class BitmapWalker {
* objectId of the commit without a bitmap in the bitmap
* index
*/
- default void onCommitWithoutBitmap(ObjectId oid) {
+ void onCommitWithoutBitmap(ObjectId oid);
+
+ }
+
+ /**
+ * Empty listener
+ *
+ * @since 6.8
+ */
+ public static final BitmapWalkListener NOOP_LISTENER = new BitmapWalkListener() {
+ @Override
+ public void onCommitSeen(ObjectId oid) {
+ // Nothing to do
+ }
+
+ @Override
+ public void onCommitWithBitmap(ObjectId oid) {
// Nothing to do
}
- }
- private static final BitmapWalkListener NO_LISTENER = new BitmapWalkListener() {
- // Default methods
+ @Override
+ public void onCommitWithoutBitmap(ObjectId oid) {
+ // Nothing to do
+ }
};
private final BitmapWalkListener listener;
@@ -100,7 +114,7 @@ public final class BitmapWalker {
*/
public BitmapWalker(
ObjectWalk walker, BitmapIndex bitmapIndex, ProgressMonitor pm) {
- this(walker, bitmapIndex, pm, NO_LISTENER);
+ this(walker, bitmapIndex, pm, NOOP_LISTENER);
}
/**
@@ -114,7 +128,7 @@ public final class BitmapWalker {
* progress monitor to report progress on.
* @param listener
* listener of event happening during the walk. Use
- * {@link #NO_LISTENER} for a no-op listener.
+ * {@link BitmapWalker#NOOP_LISTENER} for a no-op listener.
*
* @since 6.8
*/