Remove all non-static functionality from AccountGroup This had no remaining callers; the group APIs all use InternalGroup directly where applicable. Change-Id: Ic0b918af51b27929b16323d7aa5a46d2661d578f
diff --git a/java/com/google/gerrit/entities/AccountGroup.java b/java/com/google/gerrit/entities/AccountGroup.java index c10edc2..b6da194 100644 --- a/java/com/google/gerrit/entities/AccountGroup.java +++ b/java/com/google/gerrit/entities/AccountGroup.java
@@ -15,23 +15,8 @@ package com.google.gerrit.entities; import com.google.auto.value.AutoValue; -import com.google.gerrit.common.Nullable; -import java.sql.Timestamp; -import java.time.Instant; -import java.util.Objects; -/** Named group of one or more accounts, typically used for access controls. */ public final class AccountGroup { - /** - * Time when the audit subsystem was implemented, used as the default value for {@link #createdOn} - * when one couldn't be determined from the audit log. - */ - private static final Instant AUDIT_CREATION_INSTANT_MS = Instant.ofEpochMilli(1244489460000L); - - public static Timestamp auditCreationInstantTs() { - return Timestamp.from(AUDIT_CREATION_INSTANT_MS); - } - public static NameKey nameKey(String n) { return new AutoValue_AccountGroup_NameKey(n); } @@ -135,158 +120,4 @@ return Integer.toString(get()); } } - - /** Unique name of this group within the system. */ - protected NameKey name; - - /** Unique identity, to link entities as {@link #name} can change. */ - protected Id groupId; - - // DELETED: id = 3 (ownerGroupId) - - /** A textual description of the group's purpose. */ - @Nullable protected String description; - - // DELETED: id = 5 (groupType) - // DELETED: id = 6 (externalName) - - protected boolean visibleToAll; - - // DELETED: id = 8 (emailOnlyAuthors) - - /** Globally unique identifier name for this group. */ - protected UUID groupUUID; - - /** - * Identity of the group whose members can manage this group. - * - * <p>This can be a self-reference to indicate the group's members manage itself. - */ - protected UUID ownerGroupUUID; - - @Nullable protected Timestamp createdOn; - - protected AccountGroup() {} - - public AccountGroup( - AccountGroup.NameKey newName, - AccountGroup.Id newId, - AccountGroup.UUID uuid, - Timestamp createdOn) { - name = newName; - groupId = newId; - visibleToAll = false; - groupUUID = uuid; - ownerGroupUUID = groupUUID; - this.createdOn = createdOn; - } - - public AccountGroup(AccountGroup other) { - name = other.name; - groupId = other.groupId; - description = other.description; - visibleToAll = other.visibleToAll; - groupUUID = other.groupUUID; - ownerGroupUUID = other.ownerGroupUUID; - createdOn = other.createdOn; - } - - public AccountGroup.Id getId() { - return groupId; - } - - public String getName() { - return name.get(); - } - - public AccountGroup.NameKey getNameKey() { - return name; - } - - public void setNameKey(AccountGroup.NameKey nameKey) { - name = nameKey; - } - - public String getDescription() { - return description; - } - - public void setDescription(String d) { - description = d; - } - - public AccountGroup.UUID getOwnerGroupUUID() { - return ownerGroupUUID; - } - - public void setOwnerGroupUUID(AccountGroup.UUID uuid) { - ownerGroupUUID = uuid; - } - - public void setVisibleToAll(boolean visibleToAll) { - this.visibleToAll = visibleToAll; - } - - public boolean isVisibleToAll() { - return visibleToAll; - } - - public AccountGroup.UUID getGroupUUID() { - return groupUUID; - } - - public void setGroupUUID(AccountGroup.UUID uuid) { - groupUUID = uuid; - } - - public Timestamp getCreatedOn() { - return createdOn != null ? createdOn : auditCreationInstantTs(); - } - - public void setCreatedOn(Timestamp createdOn) { - this.createdOn = createdOn; - } - - @Override - public boolean equals(Object o) { - if (!(o instanceof AccountGroup)) { - return false; - } - AccountGroup g = (AccountGroup) o; - return Objects.equals(name, g.name) - && Objects.equals(groupId, g.groupId) - && Objects.equals(description, g.description) - && visibleToAll == g.visibleToAll - && Objects.equals(groupUUID, g.groupUUID) - && Objects.equals(ownerGroupUUID, g.ownerGroupUUID) - // Treat created on epoch identical regardless if underlying value is null. - && getCreatedOn().equals(g.getCreatedOn()); - } - - @Override - public int hashCode() { - return Objects.hash( - name, groupId, description, visibleToAll, groupUUID, ownerGroupUUID, createdOn); - } - - @Override - public String toString() { - return getClass().getSimpleName() - + "{" - + "name=" - + name - + ", groupId=" - + groupId - + ", description=" - + description - + ", visibleToAll=" - + visibleToAll - + ", groupUUID=" - + groupUUID - + ", ownerGroupUUID=" - + ownerGroupUUID - + ", createdOn=" - + createdOn - + "}"; - } }
diff --git a/javatests/com/google/gerrit/entities/AccountGroupTest.java b/javatests/com/google/gerrit/entities/AccountGroupTest.java index a9d5188..e0a9154 100644 --- a/javatests/com/google/gerrit/entities/AccountGroupTest.java +++ b/javatests/com/google/gerrit/entities/AccountGroupTest.java
@@ -19,11 +19,6 @@ import static com.google.gerrit.entities.AccountGroup.UUID.fromRefPart; import static com.google.gerrit.entities.AccountGroup.uuid; -import java.sql.Timestamp; -import java.time.Instant; -import java.time.LocalDateTime; -import java.time.Month; -import java.time.ZoneOffset; import org.junit.Test; public class AccountGroupTest { @@ -31,12 +26,6 @@ private static final String TEST_SHARDED_UUID = TEST_UUID.substring(0, 2) + "/" + TEST_UUID; @Test - public void auditCreationInstant() { - Instant instant = LocalDateTime.of(2009, Month.JUNE, 8, 19, 31).toInstant(ZoneOffset.UTC); - assertThat(AccountGroup.auditCreationInstantTs()).isEqualTo(Timestamp.from(instant)); - } - - @Test public void parseRefName() { assertThat(fromRef("refs/groups/" + TEST_SHARDED_UUID)).isEqualTo(uuid(TEST_UUID)); assertThat(fromRef("refs/groups/" + TEST_SHARDED_UUID + "-2"))