/*
 * 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 used by the api to get information about a Person within a BaseItem.
 */
@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "OpenAPI Generator")
public class BaseItemPerson {
    public static final String JSON_PROPERTY_NAME = "Name";
    private @org.eclipse.jdt.annotation.Nullable String name;

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

    public static final String JSON_PROPERTY_ROLE = "Role";
    private @org.eclipse.jdt.annotation.Nullable String role;

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

    public static final String JSON_PROPERTY_PRIMARY_IMAGE_TAG = "PrimaryImageTag";
    private @org.eclipse.jdt.annotation.Nullable String primaryImageTag;

    public static final String JSON_PROPERTY_IMAGE_BLUR_HASHES = "ImageBlurHashes";
    private @org.eclipse.jdt.annotation.Nullable BaseItemPersonImageBlurHashes imageBlurHashes;

    public BaseItemPerson() {
    }

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

    /**
     * Gets or sets the identifier.
     * 
     * @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 BaseItemPerson role(@org.eclipse.jdt.annotation.Nullable String role) {
        this.role = role;
        return this;
    }

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

    @JsonProperty(value = JSON_PROPERTY_ROLE)
    public void setRole(@org.eclipse.jdt.annotation.Nullable String role) {
        this.role = role;
    }

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

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

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

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

    /**
     * Gets or sets the primary image tag.
     * 
     * @return primaryImageTag
     */
    @JsonProperty(value = JSON_PROPERTY_PRIMARY_IMAGE_TAG)
    public @org.eclipse.jdt.annotation.Nullable String getPrimaryImageTag() {
        return primaryImageTag;
    }

    @JsonProperty(value = JSON_PROPERTY_PRIMARY_IMAGE_TAG)
    public void setPrimaryImageTag(@org.eclipse.jdt.annotation.Nullable String primaryImageTag) {
        this.primaryImageTag = primaryImageTag;
    }

    public BaseItemPerson imageBlurHashes(
            @org.eclipse.jdt.annotation.Nullable BaseItemPersonImageBlurHashes imageBlurHashes) {
        this.imageBlurHashes = imageBlurHashes;
        return this;
    }

    /**
     * Get imageBlurHashes
     * 
     * @return imageBlurHashes
     */
    @JsonProperty(value = JSON_PROPERTY_IMAGE_BLUR_HASHES)
    public @org.eclipse.jdt.annotation.Nullable BaseItemPersonImageBlurHashes getImageBlurHashes() {
        return imageBlurHashes;
    }

    @JsonProperty(value = JSON_PROPERTY_IMAGE_BLUR_HASHES)
    public void setImageBlurHashes(@org.eclipse.jdt.annotation.Nullable BaseItemPersonImageBlurHashes imageBlurHashes) {
        this.imageBlurHashes = imageBlurHashes;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        BaseItemPerson baseItemPerson = (BaseItemPerson) o;
        return Objects.equals(this.name, baseItemPerson.name) && Objects.equals(this.id, baseItemPerson.id)
                && Objects.equals(this.role, baseItemPerson.role) && Objects.equals(this.type, baseItemPerson.type)
                && Objects.equals(this.primaryImageTag, baseItemPerson.primaryImageTag)
                && Objects.equals(this.imageBlurHashes, baseItemPerson.imageBlurHashes);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, id, role, type, primaryImageTag, imageBlurHashes);
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("class BaseItemPerson {\n");
        sb.append("    name: ").append(toIndentedString(name)).append("\n");
        sb.append("    id: ").append(toIndentedString(id)).append("\n");
        sb.append("    role: ").append(toIndentedString(role)).append("\n");
        sb.append("    type: ").append(toIndentedString(type)).append("\n");
        sb.append("    primaryImageTag: ").append(toIndentedString(primaryImageTag)).append("\n");
        sb.append("    imageBlurHashes: ").append(toIndentedString(imageBlurHashes)).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 `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 `Role` to the URL query string
        if (getRole() != null) {
            try {
                joiner.add(String.format(java.util.Locale.ROOT, "%sRole%s=%s", prefix, suffix,
                        URLEncoder.encode(String.valueOf(getRole()), "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);
            }
        }

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

        // add `ImageBlurHashes` to the URL query string
        if (getImageBlurHashes() != null) {
            joiner.add(getImageBlurHashes().toUrlQueryString(prefix + "ImageBlurHashes" + suffix));
        }

        return joiner.toString();
    }

    public static class Builder {

        private BaseItemPerson instance;

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

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

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

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

        public BaseItemPerson.Builder role(String role) {
            this.instance.role = role;
            return this;
        }

        public BaseItemPerson.Builder type(PersonKind type) {
            this.instance.type = type;
            return this;
        }

        public BaseItemPerson.Builder primaryImageTag(String primaryImageTag) {
            this.instance.primaryImageTag = primaryImageTag;
            return this;
        }

        public BaseItemPerson.Builder imageBlurHashes(BaseItemPersonImageBlurHashes imageBlurHashes) {
            this.instance.imageBlurHashes = imageBlurHashes;
            return this;
        }

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

    /**
     * Create a builder with a shallow copy of this instance.
     */
    public BaseItemPerson.Builder toBuilder() {
        return new BaseItemPerson.Builder().name(getName()).id(getId()).role(getRole()).type(getType())
                .primaryImageTag(getPrimaryImageTag()).imageBlurHashes(getImageBlurHashes());
    }
}
