/*
 * 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;

/**
 * Class QueueItem.
 */
@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "OpenAPI Generator")
public class SyncPlayQueueItem {
    public static final String JSON_PROPERTY_ITEM_ID = "ItemId";
    private @org.eclipse.jdt.annotation.Nullable UUID itemId;

    public static final String JSON_PROPERTY_PLAYLIST_ITEM_ID = "PlaylistItemId";
    private @org.eclipse.jdt.annotation.Nullable UUID playlistItemId;

    public SyncPlayQueueItem() {
    }

    /**
     * Constructor with only readonly parameters
     */
    @JsonCreator
    public SyncPlayQueueItem(@JsonProperty(value = JSON_PROPERTY_PLAYLIST_ITEM_ID) UUID playlistItemId) {
        this();
        this.playlistItemId = playlistItemId;
    }

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

    /**
     * Gets the item identifier.
     * 
     * @return itemId
     */
    @JsonProperty(value = JSON_PROPERTY_ITEM_ID)
    public @org.eclipse.jdt.annotation.Nullable UUID getItemId() {
        return itemId;
    }

    @JsonProperty(value = JSON_PROPERTY_ITEM_ID)
    public void setItemId(@org.eclipse.jdt.annotation.Nullable UUID itemId) {
        this.itemId = itemId;
    }

    /**
     * Gets the playlist identifier of the item.
     * 
     * @return playlistItemId
     */
    @JsonProperty(value = JSON_PROPERTY_PLAYLIST_ITEM_ID)
    public @org.eclipse.jdt.annotation.Nullable UUID getPlaylistItemId() {
        return playlistItemId;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        SyncPlayQueueItem syncPlayQueueItem = (SyncPlayQueueItem) o;
        return Objects.equals(this.itemId, syncPlayQueueItem.itemId)
                && Objects.equals(this.playlistItemId, syncPlayQueueItem.playlistItemId);
    }

    @Override
    public int hashCode() {
        return Objects.hash(itemId, playlistItemId);
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("class SyncPlayQueueItem {\n");
        sb.append("    itemId: ").append(toIndentedString(itemId)).append("\n");
        sb.append("    playlistItemId: ").append(toIndentedString(playlistItemId)).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 `ItemId` to the URL query string
        if (getItemId() != null) {
            try {
                joiner.add(String.format(java.util.Locale.ROOT, "%sItemId%s=%s", prefix, suffix,
                        URLEncoder.encode(String.valueOf(getItemId()), "UTF-8").replaceAll("\\+", "%20")));
            } catch (UnsupportedEncodingException e) {
                // Should never happen, UTF-8 is always supported
                throw new RuntimeException(e);
            }
        }

        // add `PlaylistItemId` to the URL query string
        if (getPlaylistItemId() != null) {
            try {
                joiner.add(String.format(java.util.Locale.ROOT, "%sPlaylistItemId%s=%s", prefix, suffix,
                        URLEncoder.encode(String.valueOf(getPlaylistItemId()), "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 SyncPlayQueueItem instance;

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

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

        public SyncPlayQueueItem.Builder itemId(UUID itemId) {
            this.instance.itemId = itemId;
            return this;
        }

        public SyncPlayQueueItem.Builder playlistItemId(UUID playlistItemId) {
            this.instance.playlistItemId = playlistItemId;
            return this;
        }

        /**
         * returns a built SyncPlayQueueItem instance.
         *
         * The builder is not reusable.
         */
        public SyncPlayQueueItem 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 SyncPlayQueueItem.Builder builder() {
        return new SyncPlayQueueItem.Builder();
    }

    /**
     * Create a builder with a shallow copy of this instance.
     */
    public SyncPlayQueueItem.Builder toBuilder() {
        return new SyncPlayQueueItem.Builder().itemId(getItemId()).playlistItemId(getPlaylistItemId());
    }
}
