com.palantir.atlasdb.timelock.api.GetCommitTimestampRequest 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.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.annotation.Nulls;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.google.errorprone.annotations.CheckReturnValue;
import com.palantir.logsafe.Preconditions;
import com.palantir.logsafe.SafeArg;
import com.palantir.logsafe.exceptions.SafeIllegalArgumentException;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.processing.Generated;
@JsonDeserialize(builder = GetCommitTimestampRequest.Builder.class)
@Generated("com.palantir.conjure.java.types.BeanGenerator")
public final class GetCommitTimestampRequest {
private final Optional lastKnownVersion;
private GetCommitTimestampRequest(Optional lastKnownVersion) {
validateFields(lastKnownVersion);
this.lastKnownVersion = lastKnownVersion;
}
@JsonProperty("lastKnownVersion")
@JsonInclude(JsonInclude.Include.NON_ABSENT)
public Optional getLastKnownVersion() {
return this.lastKnownVersion;
}
@Override
public boolean equals(@Nullable Object other) {
return this == other
|| (other instanceof GetCommitTimestampRequest && equalTo((GetCommitTimestampRequest) other));
}
private boolean equalTo(GetCommitTimestampRequest other) {
return this.lastKnownVersion.equals(other.lastKnownVersion);
}
@Override
public int hashCode() {
return this.lastKnownVersion.hashCode();
}
@Override
public String toString() {
return "GetCommitTimestampRequest{lastKnownVersion: " + lastKnownVersion + '}';
}
public static GetCommitTimestampRequest of(ConjureIdentifiedVersion lastKnownVersion) {
return builder().lastKnownVersion(Optional.of(lastKnownVersion)).build();
}
private static void validateFields(Optional lastKnownVersion) {
List missingFields = null;
missingFields = addFieldIfMissing(missingFields, lastKnownVersion, "lastKnownVersion");
if (missingFields != null) {
throw new SafeIllegalArgumentException(
"Some required fields have not been set", SafeArg.of("missingFields", missingFields));
}
}
private static List addFieldIfMissing(List prev, Object fieldValue, String fieldName) {
List missingFields = prev;
if (fieldValue == null) {
if (missingFields == null) {
missingFields = new ArrayList<>(1);
}
missingFields.add(fieldName);
}
return missingFields;
}
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 Optional lastKnownVersion = Optional.empty();
private Builder() {}
public Builder from(GetCommitTimestampRequest other) {
checkNotBuilt();
lastKnownVersion(other.getLastKnownVersion());
return this;
}
@JsonSetter(value = "lastKnownVersion", nulls = Nulls.SKIP)
public Builder lastKnownVersion(@Nonnull Optional lastKnownVersion) {
checkNotBuilt();
this.lastKnownVersion = Preconditions.checkNotNull(lastKnownVersion, "lastKnownVersion cannot be null");
return this;
}
public Builder lastKnownVersion(@Nonnull ConjureIdentifiedVersion lastKnownVersion) {
checkNotBuilt();
this.lastKnownVersion =
Optional.of(Preconditions.checkNotNull(lastKnownVersion, "lastKnownVersion cannot be null"));
return this;
}
@CheckReturnValue
public GetCommitTimestampRequest build() {
checkNotBuilt();
this._buildInvoked = true;
return new GetCommitTimestampRequest(lastKnownVersion);
}
private void checkNotBuilt() {
Preconditions.checkState(!_buildInvoked, "Build has already been called");
}
}
}