/*
 * 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 com.fasterxml.jackson.annotation.JsonProperty;

/**
 * PlaystateRequest
 */
@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "OpenAPI Generator")
public class PlaystateRequest {
    public static final String JSON_PROPERTY_COMMAND = "Command";
    private @org.eclipse.jdt.annotation.Nullable PlaystateCommand command;

    public static final String JSON_PROPERTY_SEEK_POSITION_TICKS = "SeekPositionTicks";
    private @org.eclipse.jdt.annotation.Nullable Long seekPositionTicks;

    public static final String JSON_PROPERTY_CONTROLLING_USER_ID = "ControllingUserId";
    private @org.eclipse.jdt.annotation.Nullable String controllingUserId;

    public PlaystateRequest() {
    }

    public PlaystateRequest command(@org.eclipse.jdt.annotation.Nullable PlaystateCommand command) {
        this.command = command;
        return this;
    }

    /**
     * Enum PlaystateCommand.
     * 
     * @return command
     */
    @JsonProperty(value = JSON_PROPERTY_COMMAND)
    public @org.eclipse.jdt.annotation.Nullable PlaystateCommand getCommand() {
        return command;
    }

    @JsonProperty(value = JSON_PROPERTY_COMMAND)
    public void setCommand(@org.eclipse.jdt.annotation.Nullable PlaystateCommand command) {
        this.command = command;
    }

    public PlaystateRequest seekPositionTicks(@org.eclipse.jdt.annotation.Nullable Long seekPositionTicks) {
        this.seekPositionTicks = seekPositionTicks;
        return this;
    }

    /**
     * Get seekPositionTicks
     * 
     * @return seekPositionTicks
     */
    @JsonProperty(value = JSON_PROPERTY_SEEK_POSITION_TICKS)
    public @org.eclipse.jdt.annotation.Nullable Long getSeekPositionTicks() {
        return seekPositionTicks;
    }

    @JsonProperty(value = JSON_PROPERTY_SEEK_POSITION_TICKS)
    public void setSeekPositionTicks(@org.eclipse.jdt.annotation.Nullable Long seekPositionTicks) {
        this.seekPositionTicks = seekPositionTicks;
    }

    public PlaystateRequest controllingUserId(@org.eclipse.jdt.annotation.Nullable String controllingUserId) {
        this.controllingUserId = controllingUserId;
        return this;
    }

    /**
     * Gets or sets the controlling user identifier.
     * 
     * @return controllingUserId
     */
    @JsonProperty(value = JSON_PROPERTY_CONTROLLING_USER_ID)
    public @org.eclipse.jdt.annotation.Nullable String getControllingUserId() {
        return controllingUserId;
    }

    @JsonProperty(value = JSON_PROPERTY_CONTROLLING_USER_ID)
    public void setControllingUserId(@org.eclipse.jdt.annotation.Nullable String controllingUserId) {
        this.controllingUserId = controllingUserId;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        PlaystateRequest playstateRequest = (PlaystateRequest) o;
        return Objects.equals(this.command, playstateRequest.command)
                && Objects.equals(this.seekPositionTicks, playstateRequest.seekPositionTicks)
                && Objects.equals(this.controllingUserId, playstateRequest.controllingUserId);
    }

    @Override
    public int hashCode() {
        return Objects.hash(command, seekPositionTicks, controllingUserId);
    }

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

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

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

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

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

        public PlaystateRequest.Builder command(PlaystateCommand command) {
            this.instance.command = command;
            return this;
        }

        public PlaystateRequest.Builder seekPositionTicks(Long seekPositionTicks) {
            this.instance.seekPositionTicks = seekPositionTicks;
            return this;
        }

        public PlaystateRequest.Builder controllingUserId(String controllingUserId) {
            this.instance.controllingUserId = controllingUserId;
            return this;
        }

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

    /**
     * Create a builder with a shallow copy of this instance.
     */
    public PlaystateRequest.Builder toBuilder() {
        return new PlaystateRequest.Builder().command(getCommand()).seekPositionTicks(getSeekPositionTicks())
                .controllingUserId(getControllingUserId());
    }
}
