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

com.palantir.lock.ConjureSimpleHeldLocksToken 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.SafeArg;
import com.palantir.logsafe.exceptions.SafeIllegalArgumentException;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.processing.Generated;

@JsonDeserialize(builder = ConjureSimpleHeldLocksToken.Builder.class)
@Generated("com.palantir.conjure.java.types.BeanGenerator")
public final class ConjureSimpleHeldLocksToken {
    private final BigInteger tokenId;

    private final long creationDateMs;

    private int memoizedHashCode;

    private ConjureSimpleHeldLocksToken(BigInteger tokenId, long creationDateMs) {
        validateFields(tokenId);
        this.tokenId = tokenId;
        this.creationDateMs = creationDateMs;
    }

    @JsonProperty("tokenId")
    public BigInteger getTokenId() {
        return this.tokenId;
    }

    @JsonProperty("creationDateMs")
    public long getCreationDateMs() {
        return this.creationDateMs;
    }

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

    private boolean equalTo(ConjureSimpleHeldLocksToken other) {
        if (this.memoizedHashCode != 0
                && other.memoizedHashCode != 0
                && this.memoizedHashCode != other.memoizedHashCode) {
            return false;
        }
        return this.tokenId.equals(other.tokenId) && this.creationDateMs == other.creationDateMs;
    }

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

    @Override
    public String toString() {
        return "ConjureSimpleHeldLocksToken{tokenId: " + tokenId + ", creationDateMs: " + creationDateMs + '}';
    }

    public static ConjureSimpleHeldLocksToken of(BigInteger tokenId, long creationDateMs) {
        return builder().tokenId(tokenId).creationDateMs(creationDateMs).build();
    }

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

        private long creationDateMs;

        private boolean _creationDateMsInitialized = false;

        private Builder() {}

        public Builder from(ConjureSimpleHeldLocksToken other) {
            checkNotBuilt();
            tokenId(other.getTokenId());
            creationDateMs(other.getCreationDateMs());
            return this;
        }

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

        @JsonSetter("creationDateMs")
        public Builder creationDateMs(long creationDateMs) {
            checkNotBuilt();
            this.creationDateMs = creationDateMs;
            this._creationDateMsInitialized = true;
            return this;
        }

        private void validatePrimitiveFieldsHaveBeenInitialized() {
            List missingFields = null;
            missingFields = addFieldIfMissing(missingFields, _creationDateMsInitialized, "creationDateMs");
            if (missingFields != null) {
                throw new SafeIllegalArgumentException(
                        "Some required fields have not been set", SafeArg.of("missingFields", missingFields));
            }
        }

        private static List addFieldIfMissing(List prev, boolean initialized, String fieldName) {
            List missingFields = prev;
            if (!initialized) {
                if (missingFields == null) {
                    missingFields = new ArrayList<>(1);
                }
                missingFields.add(fieldName);
            }
            return missingFields;
        }

        public ConjureSimpleHeldLocksToken build() {
            checkNotBuilt();
            this._buildInvoked = true;
            validatePrimitiveFieldsHaveBeenInitialized();
            return new ConjureSimpleHeldLocksToken(tokenId, creationDateMs);
        }

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy