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

/**
 * This is a serializable stub class that is used by the api to provide information about installed plugins.
 */
@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "OpenAPI Generator")
public class PluginInfo {
    public static final String JSON_PROPERTY_NAME = "Name";
    private @org.eclipse.jdt.annotation.Nullable String name;

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

    public static final String JSON_PROPERTY_CONFIGURATION_FILE_NAME = "ConfigurationFileName";
    private @org.eclipse.jdt.annotation.Nullable String configurationFileName;

    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_CAN_UNINSTALL = "CanUninstall";
    private @org.eclipse.jdt.annotation.Nullable Boolean canUninstall;

    public static final String JSON_PROPERTY_HAS_IMAGE = "HasImage";
    private @org.eclipse.jdt.annotation.Nullable Boolean hasImage;

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

    public PluginInfo() {
    }

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

    /**
     * Gets or sets the name of the configuration file.
     * 
     * @return configurationFileName
     */
    @JsonProperty(value = JSON_PROPERTY_CONFIGURATION_FILE_NAME)
    public @org.eclipse.jdt.annotation.Nullable String getConfigurationFileName() {
        return configurationFileName;
    }

    @JsonProperty(value = JSON_PROPERTY_CONFIGURATION_FILE_NAME)
    public void setConfigurationFileName(@org.eclipse.jdt.annotation.Nullable String configurationFileName) {
        this.configurationFileName = configurationFileName;
    }

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

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

    @JsonProperty(value = JSON_PROPERTY_DESCRIPTION)
    public void setDescription(@org.eclipse.jdt.annotation.Nullable String description) {
        this.description = description;
    }

    public PluginInfo id(@org.eclipse.jdt.annotation.Nullable UUID id) {
        this.id = id;
        return this;
    }

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

    @JsonProperty(value = JSON_PROPERTY_ID)
    public void setId(@org.eclipse.jdt.annotation.Nullable UUID id) {
        this.id = id;
    }

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

    /**
     * Gets or sets 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;
    }

    @JsonProperty(value = JSON_PROPERTY_CAN_UNINSTALL)
    public void setCanUninstall(@org.eclipse.jdt.annotation.Nullable Boolean canUninstall) {
        this.canUninstall = canUninstall;
    }

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

    /**
     * Gets or sets a value indicating whether this plugin has a valid image.
     * 
     * @return hasImage
     */
    @JsonProperty(value = JSON_PROPERTY_HAS_IMAGE)
    public @org.eclipse.jdt.annotation.Nullable Boolean getHasImage() {
        return hasImage;
    }

    @JsonProperty(value = JSON_PROPERTY_HAS_IMAGE)
    public void setHasImage(@org.eclipse.jdt.annotation.Nullable Boolean hasImage) {
        this.hasImage = hasImage;
    }

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

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

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

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        PluginInfo pluginInfo = (PluginInfo) o;
        return Objects.equals(this.name, pluginInfo.name) && Objects.equals(this.version, pluginInfo.version)
                && Objects.equals(this.configurationFileName, pluginInfo.configurationFileName)
                && Objects.equals(this.description, pluginInfo.description) && Objects.equals(this.id, pluginInfo.id)
                && Objects.equals(this.canUninstall, pluginInfo.canUninstall)
                && Objects.equals(this.hasImage, pluginInfo.hasImage) && Objects.equals(this.status, pluginInfo.status);
    }

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

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("class PluginInfo {\n");
        sb.append("    name: ").append(toIndentedString(name)).append("\n");
        sb.append("    version: ").append(toIndentedString(version)).append("\n");
        sb.append("    configurationFileName: ").append(toIndentedString(configurationFileName)).append("\n");
        sb.append("    description: ").append(toIndentedString(description)).append("\n");
        sb.append("    id: ").append(toIndentedString(id)).append("\n");
        sb.append("    canUninstall: ").append(toIndentedString(canUninstall)).append("\n");
        sb.append("    hasImage: ").append(toIndentedString(hasImage)).append("\n");
        sb.append("    status: ").append(toIndentedString(status)).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 `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 `ConfigurationFileName` to the URL query string
        if (getConfigurationFileName() != null) {
            try {
                joiner.add(
                        String.format(java.util.Locale.ROOT, "%sConfigurationFileName%s=%s", prefix, suffix, URLEncoder
                                .encode(String.valueOf(getConfigurationFileName()), "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 `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 `HasImage` to the URL query string
        if (getHasImage() != null) {
            try {
                joiner.add(String.format(java.util.Locale.ROOT, "%sHasImage%s=%s", prefix, suffix,
                        URLEncoder.encode(String.valueOf(getHasImage()), "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);
            }
        }

        return joiner.toString();
    }

    public static class Builder {

        private PluginInfo instance;

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

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

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

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

        public PluginInfo.Builder configurationFileName(String configurationFileName) {
            this.instance.configurationFileName = configurationFileName;
            return this;
        }

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

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

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

        public PluginInfo.Builder hasImage(Boolean hasImage) {
            this.instance.hasImage = hasImage;
            return this;
        }

        public PluginInfo.Builder status(PluginStatus status) {
            this.instance.status = status;
            return this;
        }

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

    /**
     * Create a builder with a shallow copy of this instance.
     */
    public PluginInfo.Builder toBuilder() {
        return new PluginInfo.Builder().name(getName()).version(getVersion())
                .configurationFileName(getConfigurationFileName()).description(getDescription()).id(getId())
                .canUninstall(getCanUninstall()).hasImage(getHasImage()).status(getStatus());
    }
}
