All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.palantir.atlasdb.timelock.api.ConjureDeletedChangeMetadata Maven / Gradle / Ivy

There is a newer version: 0.1152.0
Show newest version
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 = ConjureDeletedChangeMetadata.Builder.class)
@Generated("com.palantir.conjure.java.types.BeanGenerator")
public final class ConjureDeletedChangeMetadata {
    private final Bytes oldValue;

    private ConjureDeletedChangeMetadata(Bytes oldValue) {
        validateFields(oldValue);
        this.oldValue = oldValue;
    }

    @JsonProperty("oldValue")
    @Unsafe
    public Bytes getOldValue() {
        return this.oldValue;
    }

    @Override
    public boolean equals(@Nullable Object other) {
        return this == other
                || (other instanceof ConjureDeletedChangeMetadata && equalTo((ConjureDeletedChangeMetadata) other));
    }

    private boolean equalTo(ConjureDeletedChangeMetadata other) {
        return this.oldValue.equals(other.oldValue);
    }

    @Override
    public int hashCode() {
        return this.oldValue.hashCode();
    }

    @Override
    @Unsafe
    public String toString() {
        return "ConjureDeletedChangeMetadata{oldValue: " + oldValue + '}';
    }

    public static ConjureDeletedChangeMetadata of(@Unsafe Bytes oldValue) {
        return builder().oldValue(oldValue).build();
    }

    private static void validateFields(Bytes oldValue) {
        List missingFields = null;
        missingFields = addFieldIfMissing(missingFields, oldValue, "oldValue");
        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 oldValue;

        private Builder() {}

        public Builder from(ConjureDeletedChangeMetadata other) {
            checkNotBuilt();
            oldValue(other.getOldValue());
            return this;
        }

        @JsonSetter("oldValue")
        public Builder oldValue(@Nonnull @Unsafe Bytes oldValue) {
            checkNotBuilt();
            this.oldValue = Preconditions.checkNotNull(oldValue, "oldValue cannot be null");
            return this;
        }

        @CheckReturnValue
        public ConjureDeletedChangeMetadata build() {
            checkNotBuilt();
            this._buildInvoked = true;
            return new ConjureDeletedChangeMetadata(oldValue);
        }

        private void checkNotBuilt() {
            Preconditions.checkState(!_buildInvoked, "Build has already been called");
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy