AccountSshKey: Remove dependency to gwtorm

This class is no longer a ReviewDb class and should be moved out of the
reviewdb.client package. For this we must not depend on gwtorm classes
like IntKey.

Change-Id: I30181547b7ddf3d9d9cab53bdd12c4b9bb792ed5
Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
Edwin Kempin
2018-02-05 11:40:21 +01:00
parent e647c35474
commit 87950e75cc

View File

@@ -14,45 +14,47 @@
package com.google.gerrit.reviewdb.client; package com.google.gerrit.reviewdb.client;
import com.google.gwtorm.client.IntKey; import java.io.Serializable;
import java.util.Objects; import java.util.Objects;
/** An SSH key approved for use by an {@link Account}. */ /** An SSH key approved for use by an {@link Account}. */
public final class AccountSshKey { public final class AccountSshKey {
public static class Id extends IntKey<Account.Id> { public static class Id implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 2L;
protected Account.Id accountId; private Account.Id accountId;
private int seq;
protected int seq;
protected Id() {
accountId = new Account.Id();
}
public Id(Account.Id a, int s) { public Id(Account.Id a, int s) {
accountId = a; accountId = a;
seq = s; seq = s;
} }
@Override
public Account.Id getParentKey() { public Account.Id getParentKey() {
return accountId; return accountId;
} }
@Override
public int get() { public int get() {
return seq; return seq;
} }
@Override
protected void set(int newValue) {
seq = newValue;
}
public boolean isValid() { public boolean isValid() {
return seq > 0; return seq > 0;
} }
@Override
public int hashCode() {
return Objects.hash(accountId, seq);
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof Id)) {
return false;
}
Id otherId = (Id) obj;
return Objects.equals(accountId, otherId.accountId) && Objects.equals(seq, otherId.seq);
}
} }
protected AccountSshKey.Id id; protected AccountSshKey.Id id;