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

com.palantir.lock.ConjureLockV1Request Maven / Gradle / Ivy

There is a newer version: 0.1193.0
Show newest version
package com.palantir.lock;

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.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 javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.processing.Generated;

@JsonDeserialize(builder = ConjureLockV1Request.Builder.class)
@Generated("com.palantir.conjure.java.types.BeanGenerator")
public final class ConjureLockV1Request {
    private final String lockClient;

    private final LockRequest lockRequest;

    private int memoizedHashCode;

    private ConjureLockV1Request(String lockClient, LockRequest lockRequest) {
        validateFields(lockClient, lockRequest);
        this.lockClient = lockClient;
        this.lockRequest = lockRequest;
    }

    @JsonProperty("lockClient")
    @Safe
    public String getLockClient() {
        return this.lockClient;
    }

    @JsonProperty("lockRequest")
    public LockRequest getLockRequest() {
        return this.lockRequest;
    }

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

    private boolean equalTo(ConjureLockV1Request other) {
        if (this.memoizedHashCode != 0
                && other.memoizedHashCode != 0
                && this.memoizedHashCode != other.memoizedHashCode) {
            return false;
        }
        return this.lockClient.equals(other.lockClient) && this.lockRequest.equals(other.lockRequest);
    }

    @Override
    public int hashCode() {
        int result = memoizedHashCode;
        if (result == 0) {
            int hash = 1;
            hash = 31 * hash + this.lockClient.hashCode();
            hash = 31 * hash + this.lockRequest.hashCode();
            result = hash;
            memoizedHashCode = result;
        }
        return result;
    }

    @Override
    public String toString() {
        return "ConjureLockV1Request{lockClient: " + lockClient + ", lockRequest: " + lockRequest + '}';
    }

    public static ConjureLockV1Request of(@Safe String lockClient, LockRequest lockRequest) {
        return builder().lockClient(lockClient).lockRequest(lockRequest).build();
    }

    private static void validateFields(String lockClient, LockRequest lockRequest) {
        List missingFields = null;
        missingFields = addFieldIfMissing(missingFields, lockClient, "lockClient");
        missingFields = addFieldIfMissing(missingFields, lockRequest, "lockRequest");
        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<>(2);
            }
            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 String lockClient;

        private LockRequest lockRequest;

        private Builder() {}

        public Builder from(ConjureLockV1Request other) {
            checkNotBuilt();
            lockClient(other.getLockClient());
            lockRequest(other.getLockRequest());
            return this;
        }

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

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

        public ConjureLockV1Request build() {
            checkNotBuilt();
            this._buildInvoked = true;
            return new ConjureLockV1Request(lockClient, lockRequest);
        }

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy