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

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

    public static final String JSON_PROPERTY_URL = "Url";
    private @org.eclipse.jdt.annotation.Nullable String url;

    public static final String JSON_PROPERTY_ENABLED = "Enabled";
    private @org.eclipse.jdt.annotation.Nullable Boolean enabled;

    public RepositoryInfo() {
    }

    public RepositoryInfo 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 RepositoryInfo url(@org.eclipse.jdt.annotation.Nullable String url) {
        this.url = url;
        return this;
    }

    /**
     * Gets or sets the URL.
     * 
     * @return url
     */
    @JsonProperty(value = JSON_PROPERTY_URL)
    public @org.eclipse.jdt.annotation.Nullable String getUrl() {
        return url;
    }

    @JsonProperty(value = JSON_PROPERTY_URL)
    public void setUrl(@org.eclipse.jdt.annotation.Nullable String url) {
        this.url = url;
    }

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

    /**
     * Gets or sets a value indicating whether the repository is enabled.
     * 
     * @return enabled
     */
    @JsonProperty(value = JSON_PROPERTY_ENABLED)
    public @org.eclipse.jdt.annotation.Nullable Boolean getEnabled() {
        return enabled;
    }

    @JsonProperty(value = JSON_PROPERTY_ENABLED)
    public void setEnabled(@org.eclipse.jdt.annotation.Nullable Boolean enabled) {
        this.enabled = enabled;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        RepositoryInfo repositoryInfo = (RepositoryInfo) o;
        return Objects.equals(this.name, repositoryInfo.name) && Objects.equals(this.url, repositoryInfo.url)
                && Objects.equals(this.enabled, repositoryInfo.enabled);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, url, enabled);
    }

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

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

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

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

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

        public RepositoryInfo.Builder url(String url) {
            this.instance.url = url;
            return this;
        }

        public RepositoryInfo.Builder enabled(Boolean enabled) {
            this.instance.enabled = enabled;
            return this;
        }

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

    /**
     * Create a builder with a shallow copy of this instance.
     */
    public RepositoryInfo.Builder toBuilder() {
        return new RepositoryInfo.Builder().name(getName()).url(getUrl()).enabled(getEnabled());
    }
}
