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