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

com.palantir.lock.ConjureLockRefreshToken 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 = ConjureLockRefreshToken.Builder.class)
@Generated("com.palantir.conjure.java.types.BeanGenerator")
public final class ConjureLockRefreshToken {
    private final BigInteger tokenId;

    private final long expirationDateMs;

    private int memoizedHashCode;

    private ConjureLockRefreshToken(BigInteger tokenId, long expirationDateMs) {
        validateFields(tokenId);
        this.tokenId = tokenId;
        this.expirationDateMs = expirationDateMs;
    }

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

    @JsonProperty("expirationDateMs")
    public long getExpirationDateMs() {
        return this.expirationDateMs;
    }

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

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

    @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.expirationDateMs);
            result = hash;
            memoizedHashCode = result;
        }
        return result;
    }

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

    public static ConjureLockRefreshToken of(BigInteger tokenId, long expirationDateMs) {
        return builder().tokenId(tokenId).expirationDateMs(expirationDateMs).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 expirationDateMs;

        private boolean _expirationDateMsInitialized = false;

        private Builder() {}

        public Builder from(ConjureLockRefreshToken other) {
            checkNotBuilt();
            tokenId(other.getTokenId());
            expirationDateMs(other.getExpirationDateMs());
            return this;
        }

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

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

        private void validatePrimitiveFieldsHaveBeenInitialized() {
            List missingFields = null;
            missingFields = addFieldIfMissing(missingFields, _expirationDateMsInitialized, "expirationDateMs");
            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 ConjureLockRefreshToken build() {
            checkNotBuilt();
            this._buildInvoked = true;
            validatePrimitiveFieldsHaveBeenInitialized();
            return new ConjureLockRefreshToken(tokenId, expirationDateMs);
        }

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy