All Downloads are FREE. Search and download functionalities are using the official Maven repository.

keywhiz.api.automation.v2.GroupDetailResponseV2 Maven / Gradle / Ivy

There is a newer version: 0.10.1
Show newest version
package keywhiz.api.automation.v2;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.auto.value.AutoValue;
import com.google.common.collect.ImmutableSet;
import keywhiz.api.model.Group;

@AutoValue public abstract class GroupDetailResponseV2 {
  GroupDetailResponseV2() {} // prevent sub-classing

  public static Builder builder() {
    return new AutoValue_GroupDetailResponseV2.Builder();
  }

  @AutoValue.Builder public abstract static class Builder {
    // intended to be package-private
    abstract Builder name(String name);
    abstract Builder description(String description);
    abstract Builder createdAtSeconds(long createdAtSeconds);
    abstract Builder updatedAtSeconds(long updatedAtSeconds);
    abstract Builder createdBy(String person);
    abstract Builder updatedBy(String person);
    abstract Builder secrets(ImmutableSet secrets);
    abstract Builder clients(ImmutableSet clients);

    public Builder group(Group group) {
      return this
          .name(group.getName())
          .description(group.getDescription())
          .createdAtSeconds(group.getCreatedAt().toEpochSecond())
          .updatedAtSeconds(group.getUpdatedAt().toEpochSecond())
          .createdBy(group.getCreatedBy())
          .updatedBy(group.getUpdatedBy());
    }

    public Builder secrets(Iterable secrets) {
      return secrets(ImmutableSet.copyOf(secrets));
    }

    public Builder clients(Iterable clients) {
      return clients(ImmutableSet.copyOf(clients));
    }

    public abstract GroupDetailResponseV2 build();
  }

  /**
   * Static factory method used by Jackson for deserialization
   */
  @SuppressWarnings("unused")
  @JsonCreator public static GroupDetailResponseV2 fromParts(
      @JsonProperty("name") String name,
      @JsonProperty("description") String description,
      @JsonProperty("createdAtSeconds") long createdAtSeconds,
      @JsonProperty("updatedAtSeconds") long updatedAtSeconds,
      @JsonProperty("createdBy") String createdBy,
      @JsonProperty("updatedBy") String updatedBy,
      @JsonProperty("secrets") Iterable secrets,
      @JsonProperty("clients") Iterable clients) {
    return builder()
        .name(name)
        .description(description)
        .createdAtSeconds(createdAtSeconds)
        .updatedAtSeconds(updatedAtSeconds)
        .createdBy(createdBy)
        .updatedBy(updatedBy)
        .secrets(secrets)
        .clients(clients)
        .build();
  }

  @JsonProperty("name") public abstract String name();
  @JsonProperty("description") public abstract String description();
  @JsonProperty("createdAtSeconds") public abstract long createdAtSeconds();
  @JsonProperty("updatedAtSeconds") public abstract long updatedAtSeconds();
  @JsonProperty("createdBy") public abstract String createdBy();
  @JsonProperty("updatedBy") public abstract String updatedBy();
  @JsonProperty("secrets") public abstract ImmutableSet secrets();
  @JsonProperty("clients") public abstract ImmutableSet clients();
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy