Skip to content

Commit 8deee15

Browse files
committed
Add a getImplementationName method to VectorizationProvider that returns the name of the selected implementation
1 parent da8c674 commit 8deee15

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

lucene/core/src/java/org/apache/lucene/internal/vectorization/VectorizationProvider.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,11 @@ public static VectorizationProvider getInstance() {
9696
Holder.INSTANCE, "call to getInstance() from subclass of VectorizationProvider");
9797
}
9898

99+
/** Returns the name of the {@code VectorizationProvider}'s implementation that's being used. */
100+
public static String getImplementationName() {
101+
return Objects.requireNonNull(Holder.INSTANCE).getName();
102+
}
103+
99104
VectorizationProvider() {
100105
// no instance/subclass except from this package
101106
}
@@ -224,6 +229,10 @@ private static void ensureCaller() {
224229
}
225230
}
226231

232+
public String getName() {
233+
return this.getClass().getSimpleName();
234+
}
235+
227236
/** This static holder class prevents classloading deadlock. */
228237
private static final class Holder {
229238
private Holder() {}

lucene/core/src/test/org/apache/lucene/internal/vectorization/TestVectorizationProvider.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ public void testCallerOfGetter() {
2424
expectThrows(UnsupportedOperationException.class, TestVectorizationProvider::illegalCaller);
2525
}
2626

27+
public void testGetProviderName() {
28+
assertEquals("DefaultVectorizationProvider", VectorizationProvider.getImplementationName());
29+
}
30+
2731
private static void illegalCaller() {
2832
VectorizationProvider.getInstance();
2933
}

0 commit comments

Comments
 (0)