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

com.spotify.autoscaler.db.ClusterResizeLogBuilder Maven / Gradle / Ivy

package com.spotify.autoscaler.db;

import io.norberg.automatter.AutoMatter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Optional;
import javax.annotation.Nullable;
import javax.annotation.processing.Generated;

@Generated("io.norberg.automatter.processor.AutoMatterProcessor")
public final class ClusterResizeLogBuilder {
  private Date timestamp;

  private String projectId;

  private String instanceId;

  private String clusterId;

  private int minNodes;

  private int maxNodes;

  private int minNodesOverride;

  private double cpuTarget;

  private double storageTarget;

  private Optional overloadStep;

  private int currentNodes;

  private int targetNodes;

  private double cpuUtilization;

  private double storageUtilization;

  private boolean success;

  private String resizeReason;

  private List resizeReasons;

  private Optional errorMessage;

  public ClusterResizeLogBuilder() {
    this.overloadStep = Optional.empty();
    this.errorMessage = Optional.empty();
  }

  private ClusterResizeLogBuilder(ClusterResizeLog v) {
    this.timestamp = v.timestamp();
    this.projectId = v.projectId();
    this.instanceId = v.instanceId();
    this.clusterId = v.clusterId();
    this.minNodes = v.minNodes();
    this.maxNodes = v.maxNodes();
    this.minNodesOverride = v.minNodesOverride();
    this.cpuTarget = v.cpuTarget();
    this.storageTarget = v.storageTarget();
    this.overloadStep = v.overloadStep();
    this.currentNodes = v.currentNodes();
    this.targetNodes = v.targetNodes();
    this.cpuUtilization = v.cpuUtilization();
    this.storageUtilization = v.storageUtilization();
    this.success = v.success();
    this.resizeReason = v.resizeReason();
    List _resizeReasons = v.resizeReasons();
    this.resizeReasons = (_resizeReasons == null) ? null : new ArrayList(_resizeReasons);
    this.errorMessage = v.errorMessage();
  }

  private ClusterResizeLogBuilder(ClusterResizeLogBuilder v) {
    this.timestamp = v.timestamp;
    this.projectId = v.projectId;
    this.instanceId = v.instanceId;
    this.clusterId = v.clusterId;
    this.minNodes = v.minNodes;
    this.maxNodes = v.maxNodes;
    this.minNodesOverride = v.minNodesOverride;
    this.cpuTarget = v.cpuTarget;
    this.storageTarget = v.storageTarget;
    this.overloadStep = v.overloadStep;
    this.currentNodes = v.currentNodes;
    this.targetNodes = v.targetNodes;
    this.cpuUtilization = v.cpuUtilization;
    this.storageUtilization = v.storageUtilization;
    this.success = v.success;
    this.resizeReason = v.resizeReason;
    this.resizeReasons = (v.resizeReasons == null) ? null : new ArrayList(v.resizeReasons);
    this.errorMessage = v.errorMessage;
  }

  public Date timestamp() {
    return timestamp;
  }

  public ClusterResizeLogBuilder timestamp(Date timestamp) {
    if (timestamp == null) {
      throw new NullPointerException("timestamp");
    }
    this.timestamp = timestamp;
    return this;
  }

  public String projectId() {
    return projectId;
  }

  public ClusterResizeLogBuilder projectId(String projectId) {
    if (projectId == null) {
      throw new NullPointerException("projectId");
    }
    this.projectId = projectId;
    return this;
  }

  public String instanceId() {
    return instanceId;
  }

  public ClusterResizeLogBuilder instanceId(String instanceId) {
    if (instanceId == null) {
      throw new NullPointerException("instanceId");
    }
    this.instanceId = instanceId;
    return this;
  }

  public String clusterId() {
    return clusterId;
  }

  public ClusterResizeLogBuilder clusterId(String clusterId) {
    if (clusterId == null) {
      throw new NullPointerException("clusterId");
    }
    this.clusterId = clusterId;
    return this;
  }

  public int minNodes() {
    return minNodes;
  }

  public ClusterResizeLogBuilder minNodes(int minNodes) {
    this.minNodes = minNodes;
    return this;
  }

  public int maxNodes() {
    return maxNodes;
  }

  public ClusterResizeLogBuilder maxNodes(int maxNodes) {
    this.maxNodes = maxNodes;
    return this;
  }

  public int minNodesOverride() {
    return minNodesOverride;
  }

  public ClusterResizeLogBuilder minNodesOverride(int minNodesOverride) {
    this.minNodesOverride = minNodesOverride;
    return this;
  }

  public double cpuTarget() {
    return cpuTarget;
  }

  public ClusterResizeLogBuilder cpuTarget(double cpuTarget) {
    this.cpuTarget = cpuTarget;
    return this;
  }

  public double storageTarget() {
    return storageTarget;
  }

  public ClusterResizeLogBuilder storageTarget(double storageTarget) {
    this.storageTarget = storageTarget;
    return this;
  }

  public Optional overloadStep() {
    return overloadStep;
  }

  public ClusterResizeLogBuilder overloadStep(Integer overloadStep) {
    return overloadStep(Optional.ofNullable(overloadStep));
  }

  @SuppressWarnings("unchecked")
  public ClusterResizeLogBuilder overloadStep(Optional overloadStep) {
    if (overloadStep == null) {
      throw new NullPointerException("overloadStep");
    }
    this.overloadStep = (Optional)overloadStep;
    return this;
  }

  public int currentNodes() {
    return currentNodes;
  }

  public ClusterResizeLogBuilder currentNodes(int currentNodes) {
    this.currentNodes = currentNodes;
    return this;
  }

  public int targetNodes() {
    return targetNodes;
  }

  public ClusterResizeLogBuilder targetNodes(int targetNodes) {
    this.targetNodes = targetNodes;
    return this;
  }

  public double cpuUtilization() {
    return cpuUtilization;
  }

  public ClusterResizeLogBuilder cpuUtilization(double cpuUtilization) {
    this.cpuUtilization = cpuUtilization;
    return this;
  }

  public double storageUtilization() {
    return storageUtilization;
  }

  public ClusterResizeLogBuilder storageUtilization(double storageUtilization) {
    this.storageUtilization = storageUtilization;
    return this;
  }

  public boolean success() {
    return success;
  }

  public ClusterResizeLogBuilder success(boolean success) {
    this.success = success;
    return this;
  }

  public String resizeReason() {
    return resizeReason;
  }

  public ClusterResizeLogBuilder resizeReason(@Nullable String resizeReason) {
    this.resizeReason = resizeReason;
    return this;
  }

  public List resizeReasons() {
    if (this.resizeReasons == null) {
      this.resizeReasons = new ArrayList();
    }
    return resizeReasons;
  }

  public ClusterResizeLogBuilder resizeReasons(List resizeReasons) {
    return resizeReasons((Collection) resizeReasons);
  }

  public ClusterResizeLogBuilder resizeReasons(Collection resizeReasons) {
    if (resizeReasons == null) {
      throw new NullPointerException("resizeReasons");
    }
    for (String item : resizeReasons) {
      if (item == null) {
        throw new NullPointerException("resizeReasons: null item");
      }
    }
    this.resizeReasons = new ArrayList(resizeReasons);
    return this;
  }

  public ClusterResizeLogBuilder resizeReasons(Iterable resizeReasons) {
    if (resizeReasons == null) {
      throw new NullPointerException("resizeReasons");
    }
    if (resizeReasons instanceof Collection) {
      return resizeReasons((Collection) resizeReasons);
    }
    return resizeReasons(resizeReasons.iterator());
  }

  public ClusterResizeLogBuilder resizeReasons(Iterator resizeReasons) {
    if (resizeReasons == null) {
      throw new NullPointerException("resizeReasons");
    }
    this.resizeReasons = new ArrayList();
    while (resizeReasons.hasNext()) {
      String item = resizeReasons.next();
      if (item == null) {
        throw new NullPointerException("resizeReasons: null item");
      }
      this.resizeReasons.add(item);
    }
    return this;
  }

  @SafeVarargs
  public final ClusterResizeLogBuilder resizeReasons(String... resizeReasons) {
    if (resizeReasons == null) {
      throw new NullPointerException("resizeReasons");
    }
    return resizeReasons(Arrays.asList(resizeReasons));
  }

  public ClusterResizeLogBuilder addResizeReason(String resizeReason) {
    if (resizeReason == null) {
      throw new NullPointerException("resizeReason");
    }
    if (this.resizeReasons == null) {
      this.resizeReasons = new ArrayList();
    }
    resizeReasons.add(resizeReason);
    return this;
  }

  public Optional errorMessage() {
    return errorMessage;
  }

  public ClusterResizeLogBuilder errorMessage(String errorMessage) {
    return errorMessage(Optional.ofNullable(errorMessage));
  }

  @SuppressWarnings("unchecked")
  public ClusterResizeLogBuilder errorMessage(Optional errorMessage) {
    if (errorMessage == null) {
      throw new NullPointerException("errorMessage");
    }
    this.errorMessage = (Optional)errorMessage;
    return this;
  }

  public ClusterResizeLog build() {
    List _resizeReasons = (resizeReasons != null) ? Collections.unmodifiableList(new ArrayList(resizeReasons)) : Collections.emptyList();
    return new Value(timestamp, projectId, instanceId, clusterId, minNodes, maxNodes, minNodesOverride, cpuTarget, storageTarget, overloadStep, currentNodes, targetNodes, cpuUtilization, storageUtilization, success, resizeReason, _resizeReasons, errorMessage);
  }

  public static ClusterResizeLogBuilder from(ClusterResizeLog v) {
    return new ClusterResizeLogBuilder(v);
  }

  public static ClusterResizeLogBuilder from(ClusterResizeLogBuilder v) {
    return new ClusterResizeLogBuilder(v);
  }

  private static final class Value implements ClusterResizeLog {
    private final Date timestamp;

    private final String projectId;

    private final String instanceId;

    private final String clusterId;

    private final int minNodes;

    private final int maxNodes;

    private final int minNodesOverride;

    private final double cpuTarget;

    private final double storageTarget;

    private final Optional overloadStep;

    private final int currentNodes;

    private final int targetNodes;

    private final double cpuUtilization;

    private final double storageUtilization;

    private final boolean success;

    private final String resizeReason;

    private final List resizeReasons;

    private final Optional errorMessage;

    private Value(@AutoMatter.Field("timestamp") Date timestamp,
        @AutoMatter.Field("projectId") String projectId,
        @AutoMatter.Field("instanceId") String instanceId,
        @AutoMatter.Field("clusterId") String clusterId, @AutoMatter.Field("minNodes") int minNodes,
        @AutoMatter.Field("maxNodes") int maxNodes,
        @AutoMatter.Field("minNodesOverride") int minNodesOverride,
        @AutoMatter.Field("cpuTarget") double cpuTarget,
        @AutoMatter.Field("storageTarget") double storageTarget,
        @AutoMatter.Field("overloadStep") Optional overloadStep,
        @AutoMatter.Field("currentNodes") int currentNodes,
        @AutoMatter.Field("targetNodes") int targetNodes,
        @AutoMatter.Field("cpuUtilization") double cpuUtilization,
        @AutoMatter.Field("storageUtilization") double storageUtilization,
        @AutoMatter.Field("success") boolean success,
        @AutoMatter.Field("resizeReason") String resizeReason,
        @AutoMatter.Field("resizeReasons") List resizeReasons,
        @AutoMatter.Field("errorMessage") Optional errorMessage) {
      if (timestamp == null) {
        throw new NullPointerException("timestamp");
      }
      if (projectId == null) {
        throw new NullPointerException("projectId");
      }
      if (instanceId == null) {
        throw new NullPointerException("instanceId");
      }
      if (clusterId == null) {
        throw new NullPointerException("clusterId");
      }
      if (overloadStep == null) {
        throw new NullPointerException("overloadStep");
      }
      if (errorMessage == null) {
        throw new NullPointerException("errorMessage");
      }
      this.timestamp = timestamp;
      this.projectId = projectId;
      this.instanceId = instanceId;
      this.clusterId = clusterId;
      this.minNodes = minNodes;
      this.maxNodes = maxNodes;
      this.minNodesOverride = minNodesOverride;
      this.cpuTarget = cpuTarget;
      this.storageTarget = storageTarget;
      this.overloadStep = overloadStep;
      this.currentNodes = currentNodes;
      this.targetNodes = targetNodes;
      this.cpuUtilization = cpuUtilization;
      this.storageUtilization = storageUtilization;
      this.success = success;
      this.resizeReason = resizeReason;
      this.resizeReasons = (resizeReasons != null) ? resizeReasons : Collections.emptyList();
      this.errorMessage = errorMessage;
    }

    @AutoMatter.Field
    @Override
    public Date timestamp() {
      return timestamp;
    }

    @AutoMatter.Field
    @Override
    public String projectId() {
      return projectId;
    }

    @AutoMatter.Field
    @Override
    public String instanceId() {
      return instanceId;
    }

    @AutoMatter.Field
    @Override
    public String clusterId() {
      return clusterId;
    }

    @AutoMatter.Field
    @Override
    public int minNodes() {
      return minNodes;
    }

    @AutoMatter.Field
    @Override
    public int maxNodes() {
      return maxNodes;
    }

    @AutoMatter.Field
    @Override
    public int minNodesOverride() {
      return minNodesOverride;
    }

    @AutoMatter.Field
    @Override
    public double cpuTarget() {
      return cpuTarget;
    }

    @AutoMatter.Field
    @Override
    public double storageTarget() {
      return storageTarget;
    }

    @AutoMatter.Field
    @Override
    public Optional overloadStep() {
      return overloadStep;
    }

    @AutoMatter.Field
    @Override
    public int currentNodes() {
      return currentNodes;
    }

    @AutoMatter.Field
    @Override
    public int targetNodes() {
      return targetNodes;
    }

    @AutoMatter.Field
    @Override
    public double cpuUtilization() {
      return cpuUtilization;
    }

    @AutoMatter.Field
    @Override
    public double storageUtilization() {
      return storageUtilization;
    }

    @AutoMatter.Field
    @Override
    public boolean success() {
      return success;
    }

    @AutoMatter.Field
    @Override
    public String resizeReason() {
      return resizeReason;
    }

    @AutoMatter.Field
    @Override
    public List resizeReasons() {
      return resizeReasons;
    }

    @AutoMatter.Field
    @Override
    public Optional errorMessage() {
      return errorMessage;
    }

    public ClusterResizeLogBuilder builder() {
      return new ClusterResizeLogBuilder(this);
    }

    @Override
    public boolean equals(Object o) {
      if (this == o) {
        return true;
      }
      if (!(o instanceof ClusterResizeLog)) {
        return false;
      }
      final ClusterResizeLog that = (ClusterResizeLog) o;
      if (timestamp != null ? !timestamp.equals(that.timestamp()) : that.timestamp() != null) {
        return false;
      }
      if (projectId != null ? !projectId.equals(that.projectId()) : that.projectId() != null) {
        return false;
      }
      if (instanceId != null ? !instanceId.equals(that.instanceId()) : that.instanceId() != null) {
        return false;
      }
      if (clusterId != null ? !clusterId.equals(that.clusterId()) : that.clusterId() != null) {
        return false;
      }
      if (minNodes != that.minNodes()) {
        return false;
      }
      if (maxNodes != that.maxNodes()) {
        return false;
      }
      if (minNodesOverride != that.minNodesOverride()) {
        return false;
      }
      if (Double.compare(cpuTarget, that.cpuTarget()) != 0) {
        return false;
      }
      if (Double.compare(storageTarget, that.storageTarget()) != 0) {
        return false;
      }
      if (overloadStep != null ? !overloadStep.equals(that.overloadStep()) : that.overloadStep() != null) {
        return false;
      }
      if (currentNodes != that.currentNodes()) {
        return false;
      }
      if (targetNodes != that.targetNodes()) {
        return false;
      }
      if (Double.compare(cpuUtilization, that.cpuUtilization()) != 0) {
        return false;
      }
      if (Double.compare(storageUtilization, that.storageUtilization()) != 0) {
        return false;
      }
      if (success != that.success()) {
        return false;
      }
      if (resizeReason != null ? !resizeReason.equals(that.resizeReason()) : that.resizeReason() != null) {
        return false;
      }
      if (resizeReasons != null ? !resizeReasons.equals(that.resizeReasons()) : that.resizeReasons() != null) {
        return false;
      }
      if (errorMessage != null ? !errorMessage.equals(that.errorMessage()) : that.errorMessage() != null) {
        return false;
      }
      return true;
    }

    @Override
    public int hashCode() {
      int result = 1;
      long temp;
      result = 31 * result + (this.timestamp != null ? this.timestamp.hashCode() : 0);
      result = 31 * result + (this.projectId != null ? this.projectId.hashCode() : 0);
      result = 31 * result + (this.instanceId != null ? this.instanceId.hashCode() : 0);
      result = 31 * result + (this.clusterId != null ? this.clusterId.hashCode() : 0);
      result = 31 * result + this.minNodes;
      result = 31 * result + this.maxNodes;
      result = 31 * result + this.minNodesOverride;
      temp = Double.doubleToLongBits(this.cpuTarget);
      result = 31 * result + (int) (temp ^ (temp >>> 32));
      temp = Double.doubleToLongBits(this.storageTarget);
      result = 31 * result + (int) (temp ^ (temp >>> 32));
      result = 31 * result + (this.overloadStep != null ? this.overloadStep.hashCode() : 0);
      result = 31 * result + this.currentNodes;
      result = 31 * result + this.targetNodes;
      temp = Double.doubleToLongBits(this.cpuUtilization);
      result = 31 * result + (int) (temp ^ (temp >>> 32));
      temp = Double.doubleToLongBits(this.storageUtilization);
      result = 31 * result + (int) (temp ^ (temp >>> 32));
      result = 31 * result + (this.success ? 1231 : 1237);
      result = 31 * result + (this.resizeReason != null ? this.resizeReason.hashCode() : 0);
      result = 31 * result + (this.resizeReasons != null ? this.resizeReasons.hashCode() : 0);
      result = 31 * result + (this.errorMessage != null ? this.errorMessage.hashCode() : 0);
      return result;
    }

    @Override
    public String toString() {
      return "ClusterResizeLog{" +
      "timestamp=" + timestamp +
      ", projectId=" + projectId +
      ", instanceId=" + instanceId +
      ", clusterId=" + clusterId +
      ", minNodes=" + minNodes +
      ", maxNodes=" + maxNodes +
      ", minNodesOverride=" + minNodesOverride +
      ", cpuTarget=" + cpuTarget +
      ", storageTarget=" + storageTarget +
      ", overloadStep=" + overloadStep +
      ", currentNodes=" + currentNodes +
      ", targetNodes=" + targetNodes +
      ", cpuUtilization=" + cpuUtilization +
      ", storageUtilization=" + storageUtilization +
      ", success=" + success +
      ", resizeReason=" + resizeReason +
      ", resizeReasons=" + resizeReasons +
      ", errorMessage=" + errorMessage +
      '}';
    }
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy