From 87950e75cc9080f0ddf090f58c40d834fd640bab Mon Sep 17 00:00:00 2001 From: Edwin Kempin Date: Mon, 5 Feb 2018 11:40:21 +0100 Subject: [PATCH] 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 --- .../gerrit/reviewdb/client/AccountSshKey.java | 36 ++++++++++--------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/java/com/google/gerrit/reviewdb/client/AccountSshKey.java b/java/com/google/gerrit/reviewdb/client/AccountSshKey.java index 372d644431..0fd8ba212b 100644 --- a/java/com/google/gerrit/reviewdb/client/AccountSshKey.java +++ b/java/com/google/gerrit/reviewdb/client/AccountSshKey.java @@ -14,45 +14,47 @@ package com.google.gerrit.reviewdb.client; -import com.google.gwtorm.client.IntKey; +import java.io.Serializable; import java.util.Objects; /** An SSH key approved for use by an {@link Account}. */ public final class AccountSshKey { - public static class Id extends IntKey { - private static final long serialVersionUID = 1L; + public static class Id implements Serializable { + private static final long serialVersionUID = 2L; - protected Account.Id accountId; - - protected int seq; - - protected Id() { - accountId = new Account.Id(); - } + private Account.Id accountId; + private int seq; public Id(Account.Id a, int s) { accountId = a; seq = s; } - @Override public Account.Id getParentKey() { return accountId; } - @Override public int get() { return seq; } - @Override - protected void set(int newValue) { - seq = newValue; - } - public boolean isValid() { 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;