From e612c2522862433c9892627aaa528f34c067349e Mon Sep 17 00:00:00 2001 From: Ivan Frade Date: Thu, 16 Nov 2023 15:12:47 -0800 Subject: [PATCH] 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 --- .../eclipse/jgit/revwalk/BitmapWalker.java | 44 ++++++++++++------- 1 file changed, 29 insertions(+), 15 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 221846242..c0e41d644 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 @@ default void onCommitInBitmap(ObjectId oid) { * @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 @@ default void onCommitWithBitmap(ObjectId oid) { * objectId of the commit without a bitmap in the bitmap * index */ - default void onCommitWithoutBitmap(ObjectId oid) { - // Nothing to do - } + void onCommitWithoutBitmap(ObjectId oid); + } - private static final BitmapWalkListener NO_LISTENER = new BitmapWalkListener() { - // Default methods + /** + * 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 + } + + @Override + public void onCommitWithoutBitmap(ObjectId oid) { + // Nothing to do + } }; private final BitmapWalkListener listener; @@ -100,7 +114,7 @@ default void onCommitWithoutBitmap(ObjectId oid) { */ 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 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 */