Skip to content

Commit 3536798

Browse files
committed
tunnel: use record class where possible
Signed-off-by: Jason A. Donenfeld <[email protected]>
1 parent 58ec110 commit 3536798

File tree

1 file changed

+2
-26
lines changed

1 file changed

+2
-26
lines changed

tunnel/src/main/java/com/wireguard/android/backend/Statistics.java

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -21,31 +21,7 @@
2121
*/
2222
@NonNullForAll
2323
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) { }
4925
private final Map<Key, PeerStats> stats = new HashMap<>();
5026
private long lastTouched = SystemClock.elapsedRealtime();
5127

@@ -85,7 +61,7 @@ public boolean isStale() {
8561
*/
8662
@Nullable
8763
public PeerStats peer(final Key peer) {
88-
return this.stats.get(peer);
64+
return stats.get(peer);
8965
}
9066

9167
/**

0 commit comments

Comments
 (0)