Skip to content

Commit 2e6db6e

Browse files
author
Vladimir Kotal
committed
use Consumer instead of the visitor interface
1 parent 3a130d5 commit 2e6db6e

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

opengrok-indexer/src/main/java/org/opengrok/indexer/history/BoundaryChangesets.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@
3434
/**
3535
* Helper class to split sequence of VCS changesets into number of intervals.
3636
* This is then used in {@link Repository#createCache(HistoryCache, String)}
37-
* to store history in chunks, for VCS repositories that supports this.
37+
* to store history in chunks, for VCS repositories that support this.
3838
*/
39-
public class BoundaryChangesets implements ChangesetVisitorInterface {
39+
public class BoundaryChangesets {
4040
private int cnt = 0;
4141
private final List<String> result = new ArrayList<>();
4242

@@ -70,7 +70,7 @@ public synchronized List<String> getBoundaryChangesetIDs(String sinceRevision) t
7070
LOGGER.log(Level.FINE, "getting boundary changesets for ''{0}''", repository.getDirectoryName());
7171
Statistics stat = new Statistics();
7272

73-
repository.accept(sinceRevision, this);
73+
repository.accept(sinceRevision, this::visit);
7474

7575
// The changesets need to go from oldest to newest.
7676
Collections.reverse(result);
@@ -85,8 +85,7 @@ public synchronized List<String> getBoundaryChangesetIDs(String sinceRevision) t
8585
return result;
8686
}
8787

88-
@Override
89-
public void visit(String id) {
88+
private void visit(String id) {
9089
if (cnt != 0 && cnt % maxCount == 0) {
9190
result.add(id);
9291
}

opengrok-indexer/src/main/java/org/opengrok/indexer/history/GitRepository.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
import java.util.concurrent.Future;
5050
import java.util.concurrent.TimeUnit;
5151
import java.util.concurrent.TimeoutException;
52+
import java.util.function.Consumer;
5253
import java.util.logging.Level;
5354
import java.util.logging.Logger;
5455
import java.util.regex.Matcher;
@@ -534,7 +535,7 @@ public int getPerPartesCount() {
534535
return MAX_CHANGESETS;
535536
}
536537

537-
public void accept(String sinceRevision, ChangesetVisitorInterface visitor) throws HistoryException {
538+
public void accept(String sinceRevision, Consumer<String> visitor) throws HistoryException {
538539
try (org.eclipse.jgit.lib.Repository repository = getJGitRepository(getDirectoryName());
539540
RevWalk walk = new RevWalk(repository)) {
540541

@@ -545,7 +546,7 @@ public void accept(String sinceRevision, ChangesetVisitorInterface visitor) thro
545546

546547
for (RevCommit commit : walk) {
547548
// Do not abbreviate the Id as this could cause AmbiguousObjectException in getHistory().
548-
visitor.visit(commit.getId().name());
549+
visitor.accept(commit.getId().name());
549550
}
550551
} catch (IOException e) {
551552
throw new HistoryException(e);

opengrok-indexer/src/main/java/org/opengrok/indexer/history/RepositoryWithPerPartesHistory.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
package org.opengrok.indexer.history;
2424

2525
import java.io.File;
26+
import java.util.function.Consumer;
2627

2728
/**
2829
* Repositories extending this class will benefit from per partes history
@@ -56,5 +57,5 @@ public int getPerPartesCount() {
5657
* @param visitor object implementing the {@link ChangesetVisitorInterface} interface
5758
* @throws HistoryException on error during history retrieval
5859
*/
59-
public abstract void accept(String sinceRevision, ChangesetVisitorInterface visitor) throws HistoryException;
60+
public abstract void accept(String sinceRevision, Consumer<String> visitor) throws HistoryException;
6061
}

0 commit comments

Comments
 (0)