com.spotify.styx.state.StateDataBuilder Maven / Gradle / Ivy
package com.spotify.styx.state;
import com.spotify.styx.model.ExecutionDescription;
import com.spotify.styx.model.TriggerParameters;
import io.norberg.automatter.AutoMatter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import javax.annotation.processing.Generated;
@Generated("io.norberg.automatter.processor.AutoMatterProcessor")
@AutoMatter.Generated
public final class StateDataBuilder {
private int tries;
private int consecutiveFailures;
private double retryCost;
private Optional retryDelayMillis;
private Optional lastExit;
private Optional trigger;
private Optional triggerId;
private Optional executionId;
private Optional runnerId;
private Optional executionDescription;
private Optional> resourceIds;
private Optional triggerParameters;
private List messages;
public StateDataBuilder() {
this.retryDelayMillis = Optional.empty();
this.lastExit = Optional.empty();
this.trigger = Optional.empty();
this.triggerId = Optional.empty();
this.executionId = Optional.empty();
this.runnerId = Optional.empty();
this.executionDescription = Optional.empty();
this.resourceIds = Optional.empty();
this.triggerParameters = Optional.empty();
}
private StateDataBuilder(StateData v) {
this.tries = v.tries();
this.consecutiveFailures = v.consecutiveFailures();
this.retryCost = v.retryCost();
this.retryDelayMillis = v.retryDelayMillis();
this.lastExit = v.lastExit();
this.trigger = v.trigger();
this.triggerId = v.triggerId();
this.executionId = v.executionId();
this.runnerId = v.runnerId();
this.executionDescription = v.executionDescription();
this.resourceIds = v.resourceIds();
this.triggerParameters = v.triggerParameters();
List _messages = v.messages();
this.messages = (_messages == null) ? null : new ArrayList(_messages);
}
private StateDataBuilder(StateDataBuilder v) {
this.tries = v.tries();
this.consecutiveFailures = v.consecutiveFailures();
this.retryCost = v.retryCost();
this.retryDelayMillis = v.retryDelayMillis();
this.lastExit = v.lastExit();
this.trigger = v.trigger();
this.triggerId = v.triggerId();
this.executionId = v.executionId();
this.runnerId = v.runnerId();
this.executionDescription = v.executionDescription();
this.resourceIds = v.resourceIds();
this.triggerParameters = v.triggerParameters();
this.messages = new ArrayList(v.messages());
}
public int tries() {
return tries;
}
public StateDataBuilder tries(int tries) {
this.tries = tries;
return this;
}
public int consecutiveFailures() {
return consecutiveFailures;
}
public StateDataBuilder consecutiveFailures(int consecutiveFailures) {
this.consecutiveFailures = consecutiveFailures;
return this;
}
public double retryCost() {
return retryCost;
}
public StateDataBuilder retryCost(double retryCost) {
this.retryCost = retryCost;
return this;
}
public Optional retryDelayMillis() {
return retryDelayMillis;
}
public StateDataBuilder retryDelayMillis(Long retryDelayMillis) {
return retryDelayMillis(Optional.ofNullable(retryDelayMillis));
}
@SuppressWarnings("unchecked")
public StateDataBuilder retryDelayMillis(Optional extends Long> retryDelayMillis) {
if (retryDelayMillis == null) {
throw new NullPointerException("retryDelayMillis");
}
this.retryDelayMillis = (Optional)retryDelayMillis;
return this;
}
public Optional lastExit() {
return lastExit;
}
public StateDataBuilder lastExit(Integer lastExit) {
return lastExit(Optional.ofNullable(lastExit));
}
@SuppressWarnings("unchecked")
public StateDataBuilder lastExit(Optional extends Integer> lastExit) {
if (lastExit == null) {
throw new NullPointerException("lastExit");
}
this.lastExit = (Optional)lastExit;
return this;
}
public Optional trigger() {
return trigger;
}
public StateDataBuilder trigger(Trigger trigger) {
return trigger(Optional.ofNullable(trigger));
}
@SuppressWarnings("unchecked")
public StateDataBuilder trigger(Optional extends Trigger> trigger) {
if (trigger == null) {
throw new NullPointerException("trigger");
}
this.trigger = (Optional)trigger;
return this;
}
public Optional triggerId() {
return triggerId;
}
public StateDataBuilder triggerId(String triggerId) {
return triggerId(Optional.ofNullable(triggerId));
}
@SuppressWarnings("unchecked")
public StateDataBuilder triggerId(Optional extends String> triggerId) {
if (triggerId == null) {
throw new NullPointerException("triggerId");
}
this.triggerId = (Optional)triggerId;
return this;
}
public Optional executionId() {
return executionId;
}
public StateDataBuilder executionId(String executionId) {
return executionId(Optional.ofNullable(executionId));
}
@SuppressWarnings("unchecked")
public StateDataBuilder executionId(Optional extends String> executionId) {
if (executionId == null) {
throw new NullPointerException("executionId");
}
this.executionId = (Optional)executionId;
return this;
}
public Optional runnerId() {
return runnerId;
}
public StateDataBuilder runnerId(String runnerId) {
return runnerId(Optional.ofNullable(runnerId));
}
@SuppressWarnings("unchecked")
public StateDataBuilder runnerId(Optional extends String> runnerId) {
if (runnerId == null) {
throw new NullPointerException("runnerId");
}
this.runnerId = (Optional)runnerId;
return this;
}
public Optional executionDescription() {
return executionDescription;
}
public StateDataBuilder executionDescription(ExecutionDescription executionDescription) {
return executionDescription(Optional.ofNullable(executionDescription));
}
@SuppressWarnings("unchecked")
public StateDataBuilder executionDescription(
Optional extends ExecutionDescription> executionDescription) {
if (executionDescription == null) {
throw new NullPointerException("executionDescription");
}
this.executionDescription = (Optional)executionDescription;
return this;
}
public Optional> resourceIds() {
return resourceIds;
}
public StateDataBuilder resourceIds(Set resourceIds) {
return resourceIds(Optional.ofNullable(resourceIds));
}
@SuppressWarnings("unchecked")
public StateDataBuilder resourceIds(Optional extends Set> resourceIds) {
if (resourceIds == null) {
throw new NullPointerException("resourceIds");
}
this.resourceIds = (Optional>)resourceIds;
return this;
}
public Optional triggerParameters() {
return triggerParameters;
}
public StateDataBuilder triggerParameters(TriggerParameters triggerParameters) {
return triggerParameters(Optional.ofNullable(triggerParameters));
}
@SuppressWarnings("unchecked")
public StateDataBuilder triggerParameters(
Optional extends TriggerParameters> triggerParameters) {
if (triggerParameters == null) {
throw new NullPointerException("triggerParameters");
}
this.triggerParameters = (Optional)triggerParameters;
return this;
}
public List messages() {
if (this.messages == null) {
this.messages = new ArrayList();
}
return messages;
}
public StateDataBuilder messages(List extends Message> messages) {
return messages((Collection extends Message>) messages);
}
public StateDataBuilder messages(Collection extends Message> messages) {
if (messages == null) {
throw new NullPointerException("messages");
}
for (Message item : messages) {
if (item == null) {
throw new NullPointerException("messages: null item");
}
}
this.messages = new ArrayList(messages);
return this;
}
public StateDataBuilder messages(Iterable extends Message> messages) {
if (messages == null) {
throw new NullPointerException("messages");
}
if (messages instanceof Collection) {
return messages((Collection extends Message>) messages);
}
return messages(messages.iterator());
}
public StateDataBuilder messages(Iterator extends Message> messages) {
if (messages == null) {
throw new NullPointerException("messages");
}
this.messages = new ArrayList();
while (messages.hasNext()) {
Message item = messages.next();
if (item == null) {
throw new NullPointerException("messages: null item");
}
this.messages.add(item);
}
return this;
}
@SafeVarargs
@SuppressWarnings("varargs")
public final StateDataBuilder messages(Message... messages) {
if (messages == null) {
throw new NullPointerException("messages");
}
return messages(Arrays.asList(messages));
}
public StateDataBuilder addMessage(Message message) {
if (message == null) {
throw new NullPointerException("message");
}
if (this.messages == null) {
this.messages = new ArrayList();
}
messages.add(message);
return this;
}
public StateDataBuilder builder() {
return new StateDataBuilder(this);
}
public StateData build() {
List _messages = (messages != null) ? Collections.unmodifiableList(new ArrayList(messages)) : Collections.emptyList();
return new Value(tries, consecutiveFailures, retryCost, retryDelayMillis, lastExit, trigger, triggerId, executionId, runnerId, executionDescription, resourceIds, triggerParameters, _messages);
}
public static StateDataBuilder from(StateData v) {
return new StateDataBuilder(v);
}
public static StateDataBuilder from(StateDataBuilder v) {
return new StateDataBuilder(v);
}
@AutoMatter.Generated
private static final class Value implements StateData {
private final int tries;
private final int consecutiveFailures;
private final double retryCost;
private final Optional retryDelayMillis;
private final Optional lastExit;
private final Optional trigger;
private final Optional triggerId;
private final Optional executionId;
private final Optional runnerId;
private final Optional executionDescription;
private final Optional> resourceIds;
private final Optional triggerParameters;
private final List messages;
private Value(@AutoMatter.Field("tries") int tries,
@AutoMatter.Field("consecutiveFailures") int consecutiveFailures,
@AutoMatter.Field("retryCost") double retryCost,
@AutoMatter.Field("retryDelayMillis") Optional retryDelayMillis,
@AutoMatter.Field("lastExit") Optional lastExit,
@AutoMatter.Field("trigger") Optional trigger,
@AutoMatter.Field("triggerId") Optional triggerId,
@AutoMatter.Field("executionId") Optional executionId,
@AutoMatter.Field("runnerId") Optional runnerId,
@AutoMatter.Field("executionDescription") Optional executionDescription,
@AutoMatter.Field("resourceIds") Optional> resourceIds,
@AutoMatter.Field("triggerParameters") Optional triggerParameters,
@AutoMatter.Field("messages") List messages) {
if (retryDelayMillis == null) {
throw new NullPointerException("retryDelayMillis");
}
if (lastExit == null) {
throw new NullPointerException("lastExit");
}
if (trigger == null) {
throw new NullPointerException("trigger");
}
if (triggerId == null) {
throw new NullPointerException("triggerId");
}
if (executionId == null) {
throw new NullPointerException("executionId");
}
if (runnerId == null) {
throw new NullPointerException("runnerId");
}
if (executionDescription == null) {
throw new NullPointerException("executionDescription");
}
if (resourceIds == null) {
throw new NullPointerException("resourceIds");
}
if (triggerParameters == null) {
throw new NullPointerException("triggerParameters");
}
this.tries = tries;
this.consecutiveFailures = consecutiveFailures;
this.retryCost = retryCost;
this.retryDelayMillis = retryDelayMillis;
this.lastExit = lastExit;
this.trigger = trigger;
this.triggerId = triggerId;
this.executionId = executionId;
this.runnerId = runnerId;
this.executionDescription = executionDescription;
this.resourceIds = resourceIds;
this.triggerParameters = triggerParameters;
this.messages = (messages != null) ? messages : Collections.emptyList();
}
@AutoMatter.Field
@Override
public int tries() {
return tries;
}
@AutoMatter.Field
@Override
public int consecutiveFailures() {
return consecutiveFailures;
}
@AutoMatter.Field
@Override
public double retryCost() {
return retryCost;
}
@AutoMatter.Field
@Override
public Optional retryDelayMillis() {
return retryDelayMillis;
}
@AutoMatter.Field
@Override
public Optional lastExit() {
return lastExit;
}
@AutoMatter.Field
@Override
public Optional trigger() {
return trigger;
}
@AutoMatter.Field
@Override
public Optional triggerId() {
return triggerId;
}
@AutoMatter.Field
@Override
public Optional executionId() {
return executionId;
}
@AutoMatter.Field
@Override
public Optional runnerId() {
return runnerId;
}
@AutoMatter.Field
@Override
public Optional executionDescription() {
return executionDescription;
}
@AutoMatter.Field
@Override
public Optional> resourceIds() {
return resourceIds;
}
@AutoMatter.Field
@Override
public Optional triggerParameters() {
return triggerParameters;
}
@AutoMatter.Field
@Override
public List messages() {
return messages;
}
@Override
public StateDataBuilder builder() {
return new StateDataBuilder(this);
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof StateData)) {
return false;
}
final StateData that = (StateData) o;
if (tries != that.tries()) {
return false;
}
if (consecutiveFailures != that.consecutiveFailures()) {
return false;
}
if (Double.compare(retryCost, that.retryCost()) != 0) {
return false;
}
if (retryDelayMillis != null ? !retryDelayMillis.equals(that.retryDelayMillis()) : that.retryDelayMillis() != null) {
return false;
}
if (lastExit != null ? !lastExit.equals(that.lastExit()) : that.lastExit() != null) {
return false;
}
if (trigger != null ? !trigger.equals(that.trigger()) : that.trigger() != null) {
return false;
}
if (triggerId != null ? !triggerId.equals(that.triggerId()) : that.triggerId() != null) {
return false;
}
if (executionId != null ? !executionId.equals(that.executionId()) : that.executionId() != null) {
return false;
}
if (runnerId != null ? !runnerId.equals(that.runnerId()) : that.runnerId() != null) {
return false;
}
if (executionDescription != null ? !executionDescription.equals(that.executionDescription()) : that.executionDescription() != null) {
return false;
}
if (resourceIds != null ? !resourceIds.equals(that.resourceIds()) : that.resourceIds() != null) {
return false;
}
if (triggerParameters != null ? !triggerParameters.equals(that.triggerParameters()) : that.triggerParameters() != null) {
return false;
}
if (messages != null ? !messages.equals(that.messages()) : that.messages() != null) {
return false;
}
return true;
}
@Override
public int hashCode() {
int result = 1;
long temp;
result = 31 * result + this.tries;
result = 31 * result + this.consecutiveFailures;
temp = Double.doubleToLongBits(this.retryCost);
result = 31 * result + (int) (temp ^ (temp >>> 32));
result = 31 * result + (this.retryDelayMillis != null ? this.retryDelayMillis.hashCode() : 0);
result = 31 * result + (this.lastExit != null ? this.lastExit.hashCode() : 0);
result = 31 * result + (this.trigger != null ? this.trigger.hashCode() : 0);
result = 31 * result + (this.triggerId != null ? this.triggerId.hashCode() : 0);
result = 31 * result + (this.executionId != null ? this.executionId.hashCode() : 0);
result = 31 * result + (this.runnerId != null ? this.runnerId.hashCode() : 0);
result = 31 * result + (this.executionDescription != null ? this.executionDescription.hashCode() : 0);
result = 31 * result + (this.resourceIds != null ? this.resourceIds.hashCode() : 0);
result = 31 * result + (this.triggerParameters != null ? this.triggerParameters.hashCode() : 0);
result = 31 * result + (this.messages != null ? this.messages.hashCode() : 0);
return result;
}
@Override
public String toString() {
return "StateData{" +
"tries=" + tries +
", consecutiveFailures=" + consecutiveFailures +
", retryCost=" + retryCost +
", retryDelayMillis=" + retryDelayMillis +
", lastExit=" + lastExit +
", trigger=" + trigger +
", triggerId=" + triggerId +
", executionId=" + executionId +
", runnerId=" + runnerId +
", executionDescription=" + executionDescription +
", resourceIds=" + resourceIds +
", triggerParameters=" + triggerParameters +
", messages=" + messages +
'}';
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy