com.palantir.atlasdb.timelock.api.ConjureGetFreshTimestampsRequest Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of timelock-api-objects Show documentation
Show all versions of timelock-api-objects Show documentation
Palantir open source project
package com.palantir.atlasdb.timelock.api;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.google.errorprone.annotations.CheckReturnValue;
import com.palantir.logsafe.Preconditions;
import com.palantir.logsafe.Safe;
import com.palantir.logsafe.SafeArg;
import com.palantir.logsafe.exceptions.SafeIllegalArgumentException;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Nullable;
import javax.annotation.processing.Generated;
@Safe
@JsonDeserialize(builder = ConjureGetFreshTimestampsRequest.Builder.class)
@Generated("com.palantir.conjure.java.types.BeanGenerator")
public final class ConjureGetFreshTimestampsRequest {
private final int numTimestamps;
private ConjureGetFreshTimestampsRequest(int numTimestamps) {
this.numTimestamps = numTimestamps;
}
@JsonProperty("numTimestamps")
@Safe
public int getNumTimestamps() {
return this.numTimestamps;
}
@Override
public boolean equals(@Nullable Object other) {
return this == other
|| (other instanceof ConjureGetFreshTimestampsRequest
&& equalTo((ConjureGetFreshTimestampsRequest) other));
}
private boolean equalTo(ConjureGetFreshTimestampsRequest other) {
return this.numTimestamps == other.numTimestamps;
}
@Override
public int hashCode() {
return this.numTimestamps;
}
@Override
@Safe
public String toString() {
return "ConjureGetFreshTimestampsRequest{numTimestamps: " + numTimestamps + '}';
}
public static ConjureGetFreshTimestampsRequest of(@Safe int numTimestamps) {
return builder().numTimestamps(numTimestamps).build();
}
public static Builder builder() {
return new Builder();
}
@Generated("com.palantir.conjure.java.types.BeanBuilderGenerator")
@JsonIgnoreProperties(ignoreUnknown = true)
public static final class Builder {
boolean _buildInvoked;
private @Safe int numTimestamps;
private boolean _numTimestampsInitialized = false;
private Builder() {}
public Builder from(ConjureGetFreshTimestampsRequest other) {
checkNotBuilt();
numTimestamps(other.getNumTimestamps());
return this;
}
@JsonSetter("numTimestamps")
public Builder numTimestamps(@Safe int numTimestamps) {
checkNotBuilt();
this.numTimestamps = numTimestamps;
this._numTimestampsInitialized = true;
return this;
}
private void validatePrimitiveFieldsHaveBeenInitialized() {
List missingFields = null;
missingFields = addFieldIfMissing(missingFields, _numTimestampsInitialized, "numTimestamps");
if (missingFields != null) {
throw new SafeIllegalArgumentException(
"Some required fields have not been set", SafeArg.of("missingFields", missingFields));
}
}
private static List addFieldIfMissing(List prev, boolean initialized, String fieldName) {
List missingFields = prev;
if (!initialized) {
if (missingFields == null) {
missingFields = new ArrayList<>(1);
}
missingFields.add(fieldName);
}
return missingFields;
}
@CheckReturnValue
public ConjureGetFreshTimestampsRequest build() {
checkNotBuilt();
this._buildInvoked = true;
validatePrimitiveFieldsHaveBeenInitialized();
return new ConjureGetFreshTimestampsRequest(numTimestamps);
}
private void checkNotBuilt() {
Preconditions.checkState(!_buildInvoked, "Build has already been called");
}
}
}