/*
 * Jellyfin API
 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
 *
 * The version of the OpenAPI document: 10.11.6
 * 
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */

package org.openhab.binding.jellyfin.internal.gen.current.model;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.Objects;
import java.util.StringJoiner;
import java.util.UUID;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
 * User deleted message.
 */
@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "OpenAPI Generator")
public class UserDeletedMessage {
    public static final String JSON_PROPERTY_DATA = "Data";
    private @org.eclipse.jdt.annotation.Nullable UUID data;

    public static final String JSON_PROPERTY_MESSAGE_ID = "MessageId";
    private @org.eclipse.jdt.annotation.Nullable UUID messageId;

    public static final String JSON_PROPERTY_MESSAGE_TYPE = "MessageType";
    private @org.eclipse.jdt.annotation.Nullable SessionMessageType messageType = SessionMessageType.USER_DELETED;

    public UserDeletedMessage() {
    }

    /**
     * Constructor with only readonly parameters
     */
    @JsonCreator
    public UserDeletedMessage(@JsonProperty(value = JSON_PROPERTY_MESSAGE_TYPE) SessionMessageType messageType) {
        this();
        this.messageType = messageType;
    }

    public UserDeletedMessage data(@org.eclipse.jdt.annotation.Nullable UUID data) {
        this.data = data;
        return this;
    }

    /**
     * Gets or sets the data.
     * 
     * @return data
     */
    @JsonProperty(value = JSON_PROPERTY_DATA)
    public @org.eclipse.jdt.annotation.Nullable UUID getData() {
        return data;
    }

    @JsonProperty(value = JSON_PROPERTY_DATA)
    public void setData(@org.eclipse.jdt.annotation.Nullable UUID data) {
        this.data = data;
    }

    public UserDeletedMessage messageId(@org.eclipse.jdt.annotation.Nullable UUID messageId) {
        this.messageId = messageId;
        return this;
    }

    /**
     * Gets or sets the message id.
     * 
     * @return messageId
     */
    @JsonProperty(value = JSON_PROPERTY_MESSAGE_ID)
    public @org.eclipse.jdt.annotation.Nullable UUID getMessageId() {
        return messageId;
    }

    @JsonProperty(value = JSON_PROPERTY_MESSAGE_ID)
    public void setMessageId(@org.eclipse.jdt.annotation.Nullable UUID messageId) {
        this.messageId = messageId;
    }

    /**
     * The different kinds of messages that are used in the WebSocket api.
     * 
     * @return messageType
     */
    @JsonProperty(value = JSON_PROPERTY_MESSAGE_TYPE)
    public @org.eclipse.jdt.annotation.Nullable SessionMessageType getMessageType() {
        return messageType;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        UserDeletedMessage userDeletedMessage = (UserDeletedMessage) o;
        return Objects.equals(this.data, userDeletedMessage.data)
                && Objects.equals(this.messageId, userDeletedMessage.messageId)
                && Objects.equals(this.messageType, userDeletedMessage.messageType);
    }

    @Override
    public int hashCode() {
        return Objects.hash(data, messageId, messageType);
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("class UserDeletedMessage {\n");
        sb.append("    data: ").append(toIndentedString(data)).append("\n");
        sb.append("    messageId: ").append(toIndentedString(messageId)).append("\n");
        sb.append("    messageType: ").append(toIndentedString(messageType)).append("\n");
        sb.append("}");
        return sb.toString();
    }

    /**
     * Convert the given object to string with each line indented by 4 spaces
     * (except the first line).
     */
    private String toIndentedString(Object o) {
        return o == null ? "null" : o.toString().replace("\n", "\n    ");
    }

    /**
     * Convert the instance into URL query string.
     *
     * @return URL query string
     */
    public String toUrlQueryString() {
        return toUrlQueryString(null);
    }

    /**
     * Convert the instance into URL query string.
     *
     * @param prefix prefix of the query string
     * @return URL query string
     */
    public String toUrlQueryString(String prefix) {
        String suffix = "";
        String containerSuffix = "";
        String containerPrefix = "";
        if (prefix == null) {
            // style=form, explode=true, e.g. /pet?name=cat&type=manx
            prefix = "";
        } else {
            // deepObject style e.g. /pet?id[name]=cat&id[type]=manx
            prefix = prefix + "[";
            suffix = "]";
            containerSuffix = "]";
            containerPrefix = "[";
        }

        StringJoiner joiner = new StringJoiner("&");

        // add `Data` to the URL query string
        if (getData() != null) {
            try {
                joiner.add(String.format(java.util.Locale.ROOT, "%sData%s=%s", prefix, suffix,
                        URLEncoder.encode(String.valueOf(getData()), "UTF-8").replaceAll("\\+", "%20")));
            } catch (UnsupportedEncodingException e) {
                // Should never happen, UTF-8 is always supported
                throw new RuntimeException(e);
            }
        }

        // add `MessageId` to the URL query string
        if (getMessageId() != null) {
            try {
                joiner.add(String.format(java.util.Locale.ROOT, "%sMessageId%s=%s", prefix, suffix,
                        URLEncoder.encode(String.valueOf(getMessageId()), "UTF-8").replaceAll("\\+", "%20")));
            } catch (UnsupportedEncodingException e) {
                // Should never happen, UTF-8 is always supported
                throw new RuntimeException(e);
            }
        }

        // add `MessageType` to the URL query string
        if (getMessageType() != null) {
            try {
                joiner.add(String.format(java.util.Locale.ROOT, "%sMessageType%s=%s", prefix, suffix,
                        URLEncoder.encode(String.valueOf(getMessageType()), "UTF-8").replaceAll("\\+", "%20")));
            } catch (UnsupportedEncodingException e) {
                // Should never happen, UTF-8 is always supported
                throw new RuntimeException(e);
            }
        }

        return joiner.toString();
    }

    public static class Builder {

        private UserDeletedMessage instance;

        public Builder() {
            this(new UserDeletedMessage());
        }

        protected Builder(UserDeletedMessage instance) {
            this.instance = instance;
        }

        public UserDeletedMessage.Builder data(UUID data) {
            this.instance.data = data;
            return this;
        }

        public UserDeletedMessage.Builder messageId(UUID messageId) {
            this.instance.messageId = messageId;
            return this;
        }

        public UserDeletedMessage.Builder messageType(SessionMessageType messageType) {
            this.instance.messageType = messageType;
            return this;
        }

        /**
         * returns a built UserDeletedMessage instance.
         *
         * The builder is not reusable.
         */
        public UserDeletedMessage build() {
            try {
                return this.instance;
            } finally {
                // ensure that this.instance is not reused
                this.instance = null;
            }
        }

        @Override
        public String toString() {
            return getClass() + "=(" + instance + ")";
        }
    }

    /**
     * Create a builder with no initialized field.
     */
    public static UserDeletedMessage.Builder builder() {
        return new UserDeletedMessage.Builder();
    }

    /**
     * Create a builder with a shallow copy of this instance.
     */
    public UserDeletedMessage.Builder toBuilder() {
        return new UserDeletedMessage.Builder().data(getData()).messageId(getMessageId()).messageType(getMessageType());
    }
}
