/*
 * 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.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.StringJoiner;

import com.fasterxml.jackson.annotation.JsonProperty;

/**
 * Class ServiceInfo.
 */
@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "OpenAPI Generator")
public class LiveTvServiceInfo {
    public static final String JSON_PROPERTY_NAME = "Name";
    private @org.eclipse.jdt.annotation.Nullable String name;

    public static final String JSON_PROPERTY_HOME_PAGE_URL = "HomePageUrl";
    private @org.eclipse.jdt.annotation.Nullable String homePageUrl;

    public static final String JSON_PROPERTY_STATUS = "Status";
    private @org.eclipse.jdt.annotation.Nullable LiveTvServiceStatus status;

    public static final String JSON_PROPERTY_STATUS_MESSAGE = "StatusMessage";
    private @org.eclipse.jdt.annotation.Nullable String statusMessage;

    public static final String JSON_PROPERTY_VERSION = "Version";
    private @org.eclipse.jdt.annotation.Nullable String version;

    public static final String JSON_PROPERTY_HAS_UPDATE_AVAILABLE = "HasUpdateAvailable";
    private @org.eclipse.jdt.annotation.Nullable Boolean hasUpdateAvailable;

    public static final String JSON_PROPERTY_IS_VISIBLE = "IsVisible";
    private @org.eclipse.jdt.annotation.Nullable Boolean isVisible;

    public static final String JSON_PROPERTY_TUNERS = "Tuners";
    private @org.eclipse.jdt.annotation.Nullable List<String> tuners;

    public LiveTvServiceInfo() {
    }

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

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

    @JsonProperty(value = JSON_PROPERTY_NAME)
    public void setName(@org.eclipse.jdt.annotation.Nullable String name) {
        this.name = name;
    }

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

    /**
     * Gets or sets the home page URL.
     * 
     * @return homePageUrl
     */
    @JsonProperty(value = JSON_PROPERTY_HOME_PAGE_URL)
    public @org.eclipse.jdt.annotation.Nullable String getHomePageUrl() {
        return homePageUrl;
    }

    @JsonProperty(value = JSON_PROPERTY_HOME_PAGE_URL)
    public void setHomePageUrl(@org.eclipse.jdt.annotation.Nullable String homePageUrl) {
        this.homePageUrl = homePageUrl;
    }

    public LiveTvServiceInfo status(@org.eclipse.jdt.annotation.Nullable LiveTvServiceStatus status) {
        this.status = status;
        return this;
    }

    /**
     * Gets or sets the status.
     * 
     * @return status
     */
    @JsonProperty(value = JSON_PROPERTY_STATUS)
    public @org.eclipse.jdt.annotation.Nullable LiveTvServiceStatus getStatus() {
        return status;
    }

    @JsonProperty(value = JSON_PROPERTY_STATUS)
    public void setStatus(@org.eclipse.jdt.annotation.Nullable LiveTvServiceStatus status) {
        this.status = status;
    }

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

    /**
     * Gets or sets the status message.
     * 
     * @return statusMessage
     */
    @JsonProperty(value = JSON_PROPERTY_STATUS_MESSAGE)
    public @org.eclipse.jdt.annotation.Nullable String getStatusMessage() {
        return statusMessage;
    }

    @JsonProperty(value = JSON_PROPERTY_STATUS_MESSAGE)
    public void setStatusMessage(@org.eclipse.jdt.annotation.Nullable String statusMessage) {
        this.statusMessage = statusMessage;
    }

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

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

    @JsonProperty(value = JSON_PROPERTY_VERSION)
    public void setVersion(@org.eclipse.jdt.annotation.Nullable String version) {
        this.version = version;
    }

    public LiveTvServiceInfo hasUpdateAvailable(@org.eclipse.jdt.annotation.Nullable Boolean hasUpdateAvailable) {
        this.hasUpdateAvailable = hasUpdateAvailable;
        return this;
    }

    /**
     * Gets or sets a value indicating whether this instance has update available.
     * 
     * @return hasUpdateAvailable
     */
    @JsonProperty(value = JSON_PROPERTY_HAS_UPDATE_AVAILABLE)
    public @org.eclipse.jdt.annotation.Nullable Boolean getHasUpdateAvailable() {
        return hasUpdateAvailable;
    }

    @JsonProperty(value = JSON_PROPERTY_HAS_UPDATE_AVAILABLE)
    public void setHasUpdateAvailable(@org.eclipse.jdt.annotation.Nullable Boolean hasUpdateAvailable) {
        this.hasUpdateAvailable = hasUpdateAvailable;
    }

    public LiveTvServiceInfo isVisible(@org.eclipse.jdt.annotation.Nullable Boolean isVisible) {
        this.isVisible = isVisible;
        return this;
    }

    /**
     * Gets or sets a value indicating whether this instance is visible.
     * 
     * @return isVisible
     */
    @JsonProperty(value = JSON_PROPERTY_IS_VISIBLE)
    public @org.eclipse.jdt.annotation.Nullable Boolean getIsVisible() {
        return isVisible;
    }

    @JsonProperty(value = JSON_PROPERTY_IS_VISIBLE)
    public void setIsVisible(@org.eclipse.jdt.annotation.Nullable Boolean isVisible) {
        this.isVisible = isVisible;
    }

    public LiveTvServiceInfo tuners(@org.eclipse.jdt.annotation.Nullable List<String> tuners) {
        this.tuners = tuners;
        return this;
    }

    public LiveTvServiceInfo addTunersItem(String tunersItem) {
        if (this.tuners == null) {
            this.tuners = new ArrayList<>();
        }
        this.tuners.add(tunersItem);
        return this;
    }

    /**
     * Get tuners
     * 
     * @return tuners
     */
    @JsonProperty(value = JSON_PROPERTY_TUNERS)
    public @org.eclipse.jdt.annotation.Nullable List<String> getTuners() {
        return tuners;
    }

    @JsonProperty(value = JSON_PROPERTY_TUNERS)
    public void setTuners(@org.eclipse.jdt.annotation.Nullable List<String> tuners) {
        this.tuners = tuners;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        LiveTvServiceInfo liveTvServiceInfo = (LiveTvServiceInfo) o;
        return Objects.equals(this.name, liveTvServiceInfo.name)
                && Objects.equals(this.homePageUrl, liveTvServiceInfo.homePageUrl)
                && Objects.equals(this.status, liveTvServiceInfo.status)
                && Objects.equals(this.statusMessage, liveTvServiceInfo.statusMessage)
                && Objects.equals(this.version, liveTvServiceInfo.version)
                && Objects.equals(this.hasUpdateAvailable, liveTvServiceInfo.hasUpdateAvailable)
                && Objects.equals(this.isVisible, liveTvServiceInfo.isVisible)
                && Objects.equals(this.tuners, liveTvServiceInfo.tuners);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, homePageUrl, status, statusMessage, version, hasUpdateAvailable, isVisible, tuners);
    }

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

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

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

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

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

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

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

        // add `Tuners` to the URL query string
        if (getTuners() != null) {
            for (int i = 0; i < getTuners().size(); i++) {
                try {
                    joiner.add(String.format(java.util.Locale.ROOT, "%sTuners%s%s=%s", prefix, suffix,
                            "".equals(suffix) ? ""
                                    : String.format(java.util.Locale.ROOT, "%s%d%s", containerPrefix, i,
                                            containerSuffix),
                            URLEncoder.encode(String.valueOf(getTuners().get(i)), "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 LiveTvServiceInfo instance;

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

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

        public LiveTvServiceInfo.Builder name(String name) {
            this.instance.name = name;
            return this;
        }

        public LiveTvServiceInfo.Builder homePageUrl(String homePageUrl) {
            this.instance.homePageUrl = homePageUrl;
            return this;
        }

        public LiveTvServiceInfo.Builder status(LiveTvServiceStatus status) {
            this.instance.status = status;
            return this;
        }

        public LiveTvServiceInfo.Builder statusMessage(String statusMessage) {
            this.instance.statusMessage = statusMessage;
            return this;
        }

        public LiveTvServiceInfo.Builder version(String version) {
            this.instance.version = version;
            return this;
        }

        public LiveTvServiceInfo.Builder hasUpdateAvailable(Boolean hasUpdateAvailable) {
            this.instance.hasUpdateAvailable = hasUpdateAvailable;
            return this;
        }

        public LiveTvServiceInfo.Builder isVisible(Boolean isVisible) {
            this.instance.isVisible = isVisible;
            return this;
        }

        public LiveTvServiceInfo.Builder tuners(List<String> tuners) {
            this.instance.tuners = tuners;
            return this;
        }

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

    /**
     * Create a builder with a shallow copy of this instance.
     */
    public LiveTvServiceInfo.Builder toBuilder() {
        return new LiveTvServiceInfo.Builder().name(getName()).homePageUrl(getHomePageUrl()).status(getStatus())
                .statusMessage(getStatusMessage()).version(getVersion()).hasUpdateAvailable(getHasUpdateAvailable())
                .isVisible(getIsVisible()).tuners(getTuners());
    }
}
