mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 10:49:06 +01:00
Extract ClientVersion inner class.
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
package org.briarproject.bramble.sync;
|
||||
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.bramble.api.sync.ClientId;
|
||||
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
|
||||
@Immutable
|
||||
@NotNullByDefault
|
||||
class ClientVersion implements Comparable<ClientVersion> {
|
||||
|
||||
final ClientId clientId;
|
||||
final int clientVersion;
|
||||
|
||||
ClientVersion(ClientId clientId, int clientVersion) {
|
||||
this.clientId = clientId;
|
||||
this.clientVersion = clientVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o instanceof ClientVersion) {
|
||||
ClientVersion cv = (ClientVersion) o;
|
||||
return clientId.equals(cv.clientId)
|
||||
&& clientVersion == cv.clientVersion;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return (clientId.hashCode() << 16) + clientVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(ClientVersion c) {
|
||||
int compare = clientId.compareTo(c.clientId);
|
||||
if (compare != 0) return compare;
|
||||
return clientVersion - c.clientVersion;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -501,39 +501,6 @@ class ClientVersioningManagerImpl implements ClientVersioningManager, Client,
|
||||
}
|
||||
}
|
||||
|
||||
private static class ClientVersion implements Comparable<ClientVersion> {
|
||||
|
||||
private final ClientId clientId;
|
||||
private final int clientVersion;
|
||||
|
||||
private ClientVersion(ClientId clientId, int clientVersion) {
|
||||
this.clientId = clientId;
|
||||
this.clientVersion = clientVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o instanceof ClientVersion) {
|
||||
ClientVersion cv = (ClientVersion) o;
|
||||
return clientId.equals(cv.clientId)
|
||||
&& clientVersion == cv.clientVersion;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return (clientId.hashCode() << 16) + clientVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(ClientVersion c) {
|
||||
int compare = clientId.compareTo(c.clientId);
|
||||
if (compare != 0) return compare;
|
||||
return clientVersion - c.clientVersion;
|
||||
}
|
||||
}
|
||||
|
||||
private static class ClientState {
|
||||
|
||||
private final ClientVersion version;
|
||||
|
||||
Reference in New Issue
Block a user