|
21 | 21 | */
|
22 | 22 | @NonNullForAll
|
23 | 23 | public class Statistics {
|
24 |
| - |
25 |
| - // TODO: switch to Java Record class once R8 supports desugaring those. |
26 |
| - public final class PeerStats { |
27 |
| - public final long rxBytes, txBytes, latestHandshakeEpochMillis; |
28 |
| - |
29 |
| - PeerStats(final long rxBytes, final long txBytes, final long latestHandshakeEpochMillis) { |
30 |
| - this.rxBytes = rxBytes; |
31 |
| - this.txBytes = txBytes; |
32 |
| - this.latestHandshakeEpochMillis = latestHandshakeEpochMillis; |
33 |
| - } |
34 |
| - |
35 |
| - @Override public boolean equals(final Object o) { |
36 |
| - if (this == o) |
37 |
| - return true; |
38 |
| - if (o == null || getClass() != o.getClass()) |
39 |
| - return false; |
40 |
| - final PeerStats stats = (PeerStats) o; |
41 |
| - return rxBytes == stats.rxBytes && txBytes == stats.txBytes && latestHandshakeEpochMillis == stats.latestHandshakeEpochMillis; |
42 |
| - } |
43 |
| - |
44 |
| - @Override public int hashCode() { |
45 |
| - return Objects.hash(rxBytes, txBytes, latestHandshakeEpochMillis); |
46 |
| - } |
47 |
| - } |
48 |
| - |
| 24 | + public record PeerStats(long rxBytes, long txBytes, long latestHandshakeEpochMillis) { } |
49 | 25 | private final Map<Key, PeerStats> stats = new HashMap<>();
|
50 | 26 | private long lastTouched = SystemClock.elapsedRealtime();
|
51 | 27 |
|
@@ -85,7 +61,7 @@ public boolean isStale() {
|
85 | 61 | */
|
86 | 62 | @Nullable
|
87 | 63 | public PeerStats peer(final Key peer) {
|
88 |
| - return this.stats.get(peer); |
| 64 | + return stats.get(peer); |
89 | 65 | }
|
90 | 66 |
|
91 | 67 | /**
|
|
0 commit comments