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

/**
 * Defines the MediaBrowser.Model.Dlna.DirectPlayProfile.
 */
@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "OpenAPI Generator")
public class DirectPlayProfile {
    public static final String JSON_PROPERTY_CONTAINER = "Container";
    private @org.eclipse.jdt.annotation.Nullable String container;

    public static final String JSON_PROPERTY_AUDIO_CODEC = "AudioCodec";
    private @org.eclipse.jdt.annotation.Nullable String audioCodec;

    public static final String JSON_PROPERTY_VIDEO_CODEC = "VideoCodec";
    private @org.eclipse.jdt.annotation.Nullable String videoCodec;

    public static final String JSON_PROPERTY_TYPE = "Type";
    private @org.eclipse.jdt.annotation.Nullable DlnaProfileType type;

    public DirectPlayProfile() {
    }

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

    /**
     * Gets or sets the container.
     * 
     * @return container
     */
    @JsonProperty(value = JSON_PROPERTY_CONTAINER)
    public @org.eclipse.jdt.annotation.Nullable String getContainer() {
        return container;
    }

    @JsonProperty(value = JSON_PROPERTY_CONTAINER)
    public void setContainer(@org.eclipse.jdt.annotation.Nullable String container) {
        this.container = container;
    }

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

    /**
     * Gets or sets the audio codec.
     * 
     * @return audioCodec
     */
    @JsonProperty(value = JSON_PROPERTY_AUDIO_CODEC)
    public @org.eclipse.jdt.annotation.Nullable String getAudioCodec() {
        return audioCodec;
    }

    @JsonProperty(value = JSON_PROPERTY_AUDIO_CODEC)
    public void setAudioCodec(@org.eclipse.jdt.annotation.Nullable String audioCodec) {
        this.audioCodec = audioCodec;
    }

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

    /**
     * Gets or sets the video codec.
     * 
     * @return videoCodec
     */
    @JsonProperty(value = JSON_PROPERTY_VIDEO_CODEC)
    public @org.eclipse.jdt.annotation.Nullable String getVideoCodec() {
        return videoCodec;
    }

    @JsonProperty(value = JSON_PROPERTY_VIDEO_CODEC)
    public void setVideoCodec(@org.eclipse.jdt.annotation.Nullable String videoCodec) {
        this.videoCodec = videoCodec;
    }

    public DirectPlayProfile type(@org.eclipse.jdt.annotation.Nullable DlnaProfileType type) {
        this.type = type;
        return this;
    }

    /**
     * Gets or sets the Dlna profile type.
     * 
     * @return type
     */
    @JsonProperty(value = JSON_PROPERTY_TYPE)
    public @org.eclipse.jdt.annotation.Nullable DlnaProfileType getType() {
        return type;
    }

    @JsonProperty(value = JSON_PROPERTY_TYPE)
    public void setType(@org.eclipse.jdt.annotation.Nullable DlnaProfileType type) {
        this.type = type;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        DirectPlayProfile directPlayProfile = (DirectPlayProfile) o;
        return Objects.equals(this.container, directPlayProfile.container)
                && Objects.equals(this.audioCodec, directPlayProfile.audioCodec)
                && Objects.equals(this.videoCodec, directPlayProfile.videoCodec)
                && Objects.equals(this.type, directPlayProfile.type);
    }

    @Override
    public int hashCode() {
        return Objects.hash(container, audioCodec, videoCodec, type);
    }

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

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

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

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

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

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

        public DirectPlayProfile.Builder container(String container) {
            this.instance.container = container;
            return this;
        }

        public DirectPlayProfile.Builder audioCodec(String audioCodec) {
            this.instance.audioCodec = audioCodec;
            return this;
        }

        public DirectPlayProfile.Builder videoCodec(String videoCodec) {
            this.instance.videoCodec = videoCodec;
            return this;
        }

        public DirectPlayProfile.Builder type(DlnaProfileType type) {
            this.instance.type = type;
            return this;
        }

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

    /**
     * Create a builder with a shallow copy of this instance.
     */
    public DirectPlayProfile.Builder toBuilder() {
        return new DirectPlayProfile.Builder().container(getContainer()).audioCodec(getAudioCodec())
                .videoCodec(getVideoCodec()).type(getType());
    }
}
