Skip to content

Commit bf23a08

Browse files
committed
SnapshotAgent: just a sub-class Snapshot, no static
1 parent 4990e78 commit bf23a08

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

agent/snapshot/src/main/java/me/hsgamer/topper/agent/snapshot/SnapshotAgent.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import java.util.stream.Stream;
1212

1313
public abstract class SnapshotAgent<K, V> implements Agent, Runnable {
14-
private final AtomicReference<Snapshot<K, V>> snapshot = new AtomicReference<>(new Snapshot<>());
14+
private final AtomicReference<Snapshot> snapshot = new AtomicReference<>(new Snapshot());
1515
private Predicate<Map.Entry<K, V>> filter = null;
1616
private Comparator<V> comparator;
1717

@@ -35,12 +35,12 @@ public void run() {
3535
Map<K, Integer> map = IntStream.range(0, list.size())
3636
.boxed()
3737
.collect(Collectors.toMap(i -> list.get(i).getKey(), i -> i));
38-
snapshot.set(new Snapshot<>(list, map));
38+
snapshot.set(new Snapshot(list, map));
3939
}
4040

4141
@Override
4242
public void stop() {
43-
snapshot.set(new Snapshot<>());
43+
snapshot.set(new Snapshot());
4444
}
4545

4646
public List<Map.Entry<K, V>> getUrgentSnapshot() {
@@ -76,7 +76,7 @@ public void setFilter(Predicate<Map.Entry<K, V>> filter) {
7676
this.filter = filter;
7777
}
7878

79-
private static final class Snapshot<K, V> {
79+
private final class Snapshot {
8080
private final List<Map.Entry<K, V>> entryList;
8181
private final Map<K, Integer> indexMap;
8282

0 commit comments

Comments
 (0)