diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2023-07-05 18:16:53 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2023-07-05 18:16:53 +0200 |
commit | 353679801e643d9e4518ba4ad73cb91b509ca1fc (patch) | |
tree | 12350a3723602066bc0675a79afb0c32e0d03ef9 /tunnel/src/main/java/com/wireguard | |
parent | 58ec110360343bc0ba368c34033b6b81f841cead (diff) |
tunnel: use record class where possible
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'tunnel/src/main/java/com/wireguard')
-rw-r--r-- | tunnel/src/main/java/com/wireguard/android/backend/Statistics.java | 28 |
1 files changed, 2 insertions, 26 deletions
diff --git a/tunnel/src/main/java/com/wireguard/android/backend/Statistics.java b/tunnel/src/main/java/com/wireguard/android/backend/Statistics.java index 9fc92c53..08b84949 100644 --- a/tunnel/src/main/java/com/wireguard/android/backend/Statistics.java +++ b/tunnel/src/main/java/com/wireguard/android/backend/Statistics.java @@ -21,31 +21,7 @@ import androidx.annotation.Nullable; */ @NonNullForAll public class Statistics { - - // TODO: switch to Java Record class once R8 supports desugaring those. - public final class PeerStats { - public final long rxBytes, txBytes, latestHandshakeEpochMillis; - - PeerStats(final long rxBytes, final long txBytes, final long latestHandshakeEpochMillis) { - this.rxBytes = rxBytes; - this.txBytes = txBytes; - this.latestHandshakeEpochMillis = latestHandshakeEpochMillis; - } - - @Override public boolean equals(final Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - final PeerStats stats = (PeerStats) o; - return rxBytes == stats.rxBytes && txBytes == stats.txBytes && latestHandshakeEpochMillis == stats.latestHandshakeEpochMillis; - } - - @Override public int hashCode() { - return Objects.hash(rxBytes, txBytes, latestHandshakeEpochMillis); - } - } - + public record PeerStats(long rxBytes, long txBytes, long latestHandshakeEpochMillis) { } private final Map<Key, PeerStats> stats = new HashMap<>(); private long lastTouched = SystemClock.elapsedRealtime(); @@ -85,7 +61,7 @@ public class Statistics { */ @Nullable public PeerStats peer(final Key peer) { - return this.stats.get(peer); + return stats.get(peer); } /** |