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

com.palantir.atlasdb.timelock.api.ConjureStartTransactionsResponse 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.palantir.lock.v2.Lease;
import com.palantir.lock.v2.LockImmutableTimestampResponse;
import com.palantir.lock.v2.PartitionedTimestamps;
import com.palantir.lock.watch.LockWatchStateUpdate;
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 javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.processing.Generated;

@JsonDeserialize(builder = ConjureStartTransactionsResponse.Builder.class)
@Generated("com.palantir.conjure.java.types.BeanGenerator")
public final class ConjureStartTransactionsResponse {
    private final LockImmutableTimestampResponse immutableTimestamp;

    private final PartitionedTimestamps timestamps;

    private final Lease lease;

    private final LockWatchStateUpdate lockWatchUpdate;

    private int memoizedHashCode;

    private ConjureStartTransactionsResponse(
            LockImmutableTimestampResponse immutableTimestamp,
            PartitionedTimestamps timestamps,
            Lease lease,
            LockWatchStateUpdate lockWatchUpdate) {
        validateFields(immutableTimestamp, timestamps, lease, lockWatchUpdate);
        this.immutableTimestamp = immutableTimestamp;
        this.timestamps = timestamps;
        this.lease = lease;
        this.lockWatchUpdate = lockWatchUpdate;
    }

    @JsonProperty("immutableTimestamp")
    public LockImmutableTimestampResponse getImmutableTimestamp() {
        return this.immutableTimestamp;
    }

    @JsonProperty("timestamps")
    public PartitionedTimestamps getTimestamps() {
        return this.timestamps;
    }

    @JsonProperty("lease")
    public Lease getLease() {
        return this.lease;
    }

    @JsonProperty("lockWatchUpdate")
    public LockWatchStateUpdate getLockWatchUpdate() {
        return this.lockWatchUpdate;
    }

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

    private boolean equalTo(ConjureStartTransactionsResponse other) {
        if (this.memoizedHashCode != 0
                && other.memoizedHashCode != 0
                && this.memoizedHashCode != other.memoizedHashCode) {
            return false;
        }
        return this.immutableTimestamp.equals(other.immutableTimestamp)
                && this.timestamps.equals(other.timestamps)
                && this.lease.equals(other.lease)
                && this.lockWatchUpdate.equals(other.lockWatchUpdate);
    }

    @Override
    public int hashCode() {
        int result = memoizedHashCode;
        if (result == 0) {
            int hash = 1;
            hash = 31 * hash + this.immutableTimestamp.hashCode();
            hash = 31 * hash + this.timestamps.hashCode();
            hash = 31 * hash + this.lease.hashCode();
            hash = 31 * hash + this.lockWatchUpdate.hashCode();
            result = hash;
            memoizedHashCode = result;
        }
        return result;
    }

    @Override
    public String toString() {
        return "ConjureStartTransactionsResponse{immutableTimestamp: " + immutableTimestamp + ", timestamps: "
                + timestamps + ", lease: " + lease + ", lockWatchUpdate: " + lockWatchUpdate + '}';
    }

    private static void validateFields(
            LockImmutableTimestampResponse immutableTimestamp,
            PartitionedTimestamps timestamps,
            Lease lease,
            LockWatchStateUpdate lockWatchUpdate) {
        List missingFields = null;
        missingFields = addFieldIfMissing(missingFields, immutableTimestamp, "immutableTimestamp");
        missingFields = addFieldIfMissing(missingFields, timestamps, "timestamps");
        missingFields = addFieldIfMissing(missingFields, lease, "lease");
        missingFields = addFieldIfMissing(missingFields, lockWatchUpdate, "lockWatchUpdate");
        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<>(4);
            }
            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 LockImmutableTimestampResponse immutableTimestamp;

        private PartitionedTimestamps timestamps;

        private Lease lease;

        private LockWatchStateUpdate lockWatchUpdate;

        private Builder() {}

        public Builder from(ConjureStartTransactionsResponse other) {
            checkNotBuilt();
            immutableTimestamp(other.getImmutableTimestamp());
            timestamps(other.getTimestamps());
            lease(other.getLease());
            lockWatchUpdate(other.getLockWatchUpdate());
            return this;
        }

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

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

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

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

        public ConjureStartTransactionsResponse build() {
            checkNotBuilt();
            this._buildInvoked = true;
            return new ConjureStartTransactionsResponse(immutableTimestamp, timestamps, lease, lockWatchUpdate);
        }

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy