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

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

    public static final String JSON_PROPERTY_DESCRIPTION = "Description";
    private @org.eclipse.jdt.annotation.Nullable String description;

    public static final String JSON_PROPERTY_ID = "Id";
    private @org.eclipse.jdt.annotation.Nullable UUID id;

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

    public static final String JSON_PROPERTY_ASSEMBLY_FILE_PATH = "AssemblyFilePath";
    private @org.eclipse.jdt.annotation.Nullable String assemblyFilePath;

    public static final String JSON_PROPERTY_CAN_UNINSTALL = "CanUninstall";
    private @org.eclipse.jdt.annotation.Nullable Boolean canUninstall;

    public static final String JSON_PROPERTY_DATA_FOLDER_PATH = "DataFolderPath";
    private @org.eclipse.jdt.annotation.Nullable String dataFolderPath;

    public IPlugin() {
    }

    /**
     * Constructor with only readonly parameters
     */
    @JsonCreator
    public IPlugin(@JsonProperty(value = JSON_PROPERTY_NAME) String name,
            @JsonProperty(value = JSON_PROPERTY_DESCRIPTION) String description,
            @JsonProperty(value = JSON_PROPERTY_ID) UUID id,
            @JsonProperty(value = JSON_PROPERTY_VERSION) String version,
            @JsonProperty(value = JSON_PROPERTY_ASSEMBLY_FILE_PATH) String assemblyFilePath,
            @JsonProperty(value = JSON_PROPERTY_CAN_UNINSTALL) Boolean canUninstall,
            @JsonProperty(value = JSON_PROPERTY_DATA_FOLDER_PATH) String dataFolderPath) {
        this();
        this.name = name;
        this.description = description;
        this.id = id;
        this.version = version;
        this.assemblyFilePath = assemblyFilePath;
        this.canUninstall = canUninstall;
        this.dataFolderPath = dataFolderPath;
    }

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

    /**
     * Gets the Description.
     * 
     * @return description
     */
    @JsonProperty(value = JSON_PROPERTY_DESCRIPTION)
    public @org.eclipse.jdt.annotation.Nullable String getDescription() {
        return description;
    }

    /**
     * Gets the unique id.
     * 
     * @return id
     */
    @JsonProperty(value = JSON_PROPERTY_ID)
    public @org.eclipse.jdt.annotation.Nullable UUID getId() {
        return id;
    }

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

    /**
     * Gets the path to the assembly file.
     * 
     * @return assemblyFilePath
     */
    @JsonProperty(value = JSON_PROPERTY_ASSEMBLY_FILE_PATH)
    public @org.eclipse.jdt.annotation.Nullable String getAssemblyFilePath() {
        return assemblyFilePath;
    }

    /**
     * Gets a value indicating whether the plugin can be uninstalled.
     * 
     * @return canUninstall
     */
    @JsonProperty(value = JSON_PROPERTY_CAN_UNINSTALL)
    public @org.eclipse.jdt.annotation.Nullable Boolean getCanUninstall() {
        return canUninstall;
    }

    /**
     * Gets the full path to the data folder, where the plugin can store any miscellaneous files needed.
     * 
     * @return dataFolderPath
     */
    @JsonProperty(value = JSON_PROPERTY_DATA_FOLDER_PATH)
    public @org.eclipse.jdt.annotation.Nullable String getDataFolderPath() {
        return dataFolderPath;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        IPlugin iplugin = (IPlugin) o;
        return Objects.equals(this.name, iplugin.name) && Objects.equals(this.description, iplugin.description)
                && Objects.equals(this.id, iplugin.id) && Objects.equals(this.version, iplugin.version)
                && Objects.equals(this.assemblyFilePath, iplugin.assemblyFilePath)
                && Objects.equals(this.canUninstall, iplugin.canUninstall)
                && Objects.equals(this.dataFolderPath, iplugin.dataFolderPath);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, description, id, version, assemblyFilePath, canUninstall, dataFolderPath);
    }

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

        // add `Id` to the URL query string
        if (getId() != null) {
            try {
                joiner.add(String.format(java.util.Locale.ROOT, "%sId%s=%s", prefix, suffix,
                        URLEncoder.encode(String.valueOf(getId()), "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 `AssemblyFilePath` to the URL query string
        if (getAssemblyFilePath() != null) {
            try {
                joiner.add(String.format(java.util.Locale.ROOT, "%sAssemblyFilePath%s=%s", prefix, suffix,
                        URLEncoder.encode(String.valueOf(getAssemblyFilePath()), "UTF-8").replaceAll("\\+", "%20")));
            } catch (UnsupportedEncodingException e) {
                // Should never happen, UTF-8 is always supported
                throw new RuntimeException(e);
            }
        }

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

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

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

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

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

        public IPlugin.Builder description(String description) {
            this.instance.description = description;
            return this;
        }

        public IPlugin.Builder id(UUID id) {
            this.instance.id = id;
            return this;
        }

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

        public IPlugin.Builder assemblyFilePath(String assemblyFilePath) {
            this.instance.assemblyFilePath = assemblyFilePath;
            return this;
        }

        public IPlugin.Builder canUninstall(Boolean canUninstall) {
            this.instance.canUninstall = canUninstall;
            return this;
        }

        public IPlugin.Builder dataFolderPath(String dataFolderPath) {
            this.instance.dataFolderPath = dataFolderPath;
            return this;
        }

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

    /**
     * Create a builder with a shallow copy of this instance.
     */
    public IPlugin.Builder toBuilder() {
        return new IPlugin.Builder().name(getName()).description(getDescription()).id(getId()).version(getVersion())
                .assemblyFilePath(getAssemblyFilePath()).canUninstall(getCanUninstall())
                .dataFolderPath(getDataFolderPath());
    }
}
