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

com.supertokens.api.resources.usermetadata.requests.UserMetadataReadRequest Maven / Gradle / Ivy

The newest version!
package com.supertokens.api.resources.usermetadata.requests;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.annotation.Nulls;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import java.util.Objects;
import java.util.Optional;

@JsonDeserialize(builder = UserMetadataReadRequest.Builder.class)
public final class UserMetadataReadRequest {
    private final Optional rid;

    private final String userId;

    private int _cachedHashCode;

    UserMetadataReadRequest(Optional rid, String userId) {
        this.rid = rid;
        this.userId = userId;
    }

    @JsonProperty("rid")
    public Optional getRid() {
        return rid;
    }

    @JsonProperty("userId")
    public String getUserId() {
        return userId;
    }

    @Override
    public boolean equals(Object other) {
        if (this == other) return true;
        return other instanceof UserMetadataReadRequest && equalTo((UserMetadataReadRequest) other);
    }

    private boolean equalTo(UserMetadataReadRequest other) {
        return rid.equals(other.rid) && userId.equals(other.userId);
    }

    @Override
    public int hashCode() {
        if (_cachedHashCode == 0) {
            _cachedHashCode = Objects.hash(this.rid, this.userId);
        }
        return _cachedHashCode;
    }

    @Override
    public String toString() {
        return "UserMetadataReadRequest{" + "rid: " + rid + ", userId: " + userId + "}";
    }

    public static UserIdStage builder() {
        return new Builder();
    }

    public interface UserIdStage {
        _FinalStage userId(String userId);

        Builder from(UserMetadataReadRequest other);
    }

    public interface _FinalStage {
        UserMetadataReadRequest build();

        _FinalStage rid(Optional rid);

        _FinalStage rid(String rid);
    }

    @JsonIgnoreProperties(ignoreUnknown = true)
    public static final class Builder implements UserIdStage, _FinalStage {
        private String userId;

        private Optional rid = Optional.empty();

        private Builder() {}

        @Override
        public Builder from(UserMetadataReadRequest other) {
            rid(other.getRid());
            userId(other.getUserId());
            return this;
        }

        @Override
        @JsonSetter("userId")
        public _FinalStage userId(String userId) {
            this.userId = userId;
            return this;
        }

        @Override
        public _FinalStage rid(String rid) {
            this.rid = Optional.of(rid);
            return this;
        }

        @Override
        @JsonSetter(value = "rid", nulls = Nulls.SKIP)
        public _FinalStage rid(Optional rid) {
            this.rid = rid;
            return this;
        }

        @Override
        public UserMetadataReadRequest build() {
            return new UserMetadataReadRequest(rid, userId);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy