com.palantir.atlasdb.timelock.api.ConjureLockToken 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 java.util.UUID;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.processing.Generated;
@Safe
@JsonDeserialize(builder = ConjureLockToken.Builder.class)
@Generated("com.palantir.conjure.java.types.BeanGenerator")
public final class ConjureLockToken {
private final UUID requestId;
private ConjureLockToken(UUID requestId) {
validateFields(requestId);
this.requestId = requestId;
}
@JsonProperty("requestId")
@Safe
public UUID getRequestId() {
return this.requestId;
}
@Override
public boolean equals(@Nullable Object other) {
return this == other || (other instanceof ConjureLockToken && equalTo((ConjureLockToken) other));
}
private boolean equalTo(ConjureLockToken other) {
return this.requestId.equals(other.requestId);
}
@Override
public int hashCode() {
return this.requestId.hashCode();
}
@Override
@Safe
public String toString() {
return "ConjureLockToken{requestId: " + requestId + '}';
}
public static ConjureLockToken of(@Safe UUID requestId) {
return builder().requestId(requestId).build();
}
private static void validateFields(UUID requestId) {
List missingFields = null;
missingFields = addFieldIfMissing(missingFields, requestId, "requestId");
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 @Safe UUID requestId;
private Builder() {}
public Builder from(ConjureLockToken other) {
checkNotBuilt();
requestId(other.getRequestId());
return this;
}
@JsonSetter("requestId")
public Builder requestId(@Nonnull @Safe UUID requestId) {
checkNotBuilt();
this.requestId = Preconditions.checkNotNull(requestId, "requestId cannot be null");
return this;
}
@CheckReturnValue
public ConjureLockToken build() {
checkNotBuilt();
this._buildInvoked = true;
return new ConjureLockToken(requestId);
}
private void checkNotBuilt() {
Preconditions.checkState(!_buildInvoked, "Build has already been called");
}
}
}