public record GroupKey()

in sources/src/main/java/com/google/solutions/jitaccess/apis/clients/GroupKey.java [33:65]


public record GroupKey(@NotNull String id) {
  private static final String GROUPS_PREFIX = "groups/";

  public GroupKey {
    Preconditions.checkNotNull(id, "id");

    if (id.startsWith(GROUPS_PREFIX)) {
      id = id.substring(GROUPS_PREFIX.length());
    }
  }

  @Override
  public boolean equals(@Nullable Object o) {
    if (this == o) {
      return true;
    }

    if (o == null || getClass() != o.getClass()) {
      return false;
    }

    GroupKey other = (GroupKey) o;
    return this.id.equals(other.id);
  }

  /**
   * @return ID in groups/ID format.
   */
  @Override
  public String toString() {
    return String.format("%s%s", GROUPS_PREFIX, this.id);
  }
}