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

/**
 * BoxSetInfoRemoteSearchQuery
 */
@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "OpenAPI Generator")
public class BoxSetInfoRemoteSearchQuery {
    public static final String JSON_PROPERTY_SEARCH_INFO = "SearchInfo";
    private @org.eclipse.jdt.annotation.Nullable BoxSetInfo searchInfo;

    public static final String JSON_PROPERTY_ITEM_ID = "ItemId";
    private @org.eclipse.jdt.annotation.Nullable UUID itemId;

    public static final String JSON_PROPERTY_SEARCH_PROVIDER_NAME = "SearchProviderName";
    private @org.eclipse.jdt.annotation.Nullable String searchProviderName;

    public static final String JSON_PROPERTY_INCLUDE_DISABLED_PROVIDERS = "IncludeDisabledProviders";
    private @org.eclipse.jdt.annotation.Nullable Boolean includeDisabledProviders;

    public BoxSetInfoRemoteSearchQuery() {
    }

    public BoxSetInfoRemoteSearchQuery searchInfo(@org.eclipse.jdt.annotation.Nullable BoxSetInfo searchInfo) {
        this.searchInfo = searchInfo;
        return this;
    }

    /**
     * Get searchInfo
     * 
     * @return searchInfo
     */
    @JsonProperty(value = JSON_PROPERTY_SEARCH_INFO)
    public @org.eclipse.jdt.annotation.Nullable BoxSetInfo getSearchInfo() {
        return searchInfo;
    }

    @JsonProperty(value = JSON_PROPERTY_SEARCH_INFO)
    public void setSearchInfo(@org.eclipse.jdt.annotation.Nullable BoxSetInfo searchInfo) {
        this.searchInfo = searchInfo;
    }

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

    /**
     * Get itemId
     * 
     * @return itemId
     */
    @JsonProperty(value = JSON_PROPERTY_ITEM_ID)
    public @org.eclipse.jdt.annotation.Nullable UUID getItemId() {
        return itemId;
    }

    @JsonProperty(value = JSON_PROPERTY_ITEM_ID)
    public void setItemId(@org.eclipse.jdt.annotation.Nullable UUID itemId) {
        this.itemId = itemId;
    }

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

    /**
     * Gets or sets the provider name to search within if set.
     * 
     * @return searchProviderName
     */
    @JsonProperty(value = JSON_PROPERTY_SEARCH_PROVIDER_NAME)
    public @org.eclipse.jdt.annotation.Nullable String getSearchProviderName() {
        return searchProviderName;
    }

    @JsonProperty(value = JSON_PROPERTY_SEARCH_PROVIDER_NAME)
    public void setSearchProviderName(@org.eclipse.jdt.annotation.Nullable String searchProviderName) {
        this.searchProviderName = searchProviderName;
    }

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

    /**
     * Gets or sets a value indicating whether disabled providers should be included.
     * 
     * @return includeDisabledProviders
     */
    @JsonProperty(value = JSON_PROPERTY_INCLUDE_DISABLED_PROVIDERS)
    public @org.eclipse.jdt.annotation.Nullable Boolean getIncludeDisabledProviders() {
        return includeDisabledProviders;
    }

    @JsonProperty(value = JSON_PROPERTY_INCLUDE_DISABLED_PROVIDERS)
    public void setIncludeDisabledProviders(@org.eclipse.jdt.annotation.Nullable Boolean includeDisabledProviders) {
        this.includeDisabledProviders = includeDisabledProviders;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        BoxSetInfoRemoteSearchQuery boxSetInfoRemoteSearchQuery = (BoxSetInfoRemoteSearchQuery) o;
        return Objects.equals(this.searchInfo, boxSetInfoRemoteSearchQuery.searchInfo)
                && Objects.equals(this.itemId, boxSetInfoRemoteSearchQuery.itemId)
                && Objects.equals(this.searchProviderName, boxSetInfoRemoteSearchQuery.searchProviderName)
                && Objects.equals(this.includeDisabledProviders, boxSetInfoRemoteSearchQuery.includeDisabledProviders);
    }

    @Override
    public int hashCode() {
        return Objects.hash(searchInfo, itemId, searchProviderName, includeDisabledProviders);
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("class BoxSetInfoRemoteSearchQuery {\n");
        sb.append("    searchInfo: ").append(toIndentedString(searchInfo)).append("\n");
        sb.append("    itemId: ").append(toIndentedString(itemId)).append("\n");
        sb.append("    searchProviderName: ").append(toIndentedString(searchProviderName)).append("\n");
        sb.append("    includeDisabledProviders: ").append(toIndentedString(includeDisabledProviders)).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 `SearchInfo` to the URL query string
        if (getSearchInfo() != null) {
            joiner.add(getSearchInfo().toUrlQueryString(prefix + "SearchInfo" + suffix));
        }

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

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

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

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

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

        public BoxSetInfoRemoteSearchQuery.Builder searchInfo(BoxSetInfo searchInfo) {
            this.instance.searchInfo = searchInfo;
            return this;
        }

        public BoxSetInfoRemoteSearchQuery.Builder itemId(UUID itemId) {
            this.instance.itemId = itemId;
            return this;
        }

        public BoxSetInfoRemoteSearchQuery.Builder searchProviderName(String searchProviderName) {
            this.instance.searchProviderName = searchProviderName;
            return this;
        }

        public BoxSetInfoRemoteSearchQuery.Builder includeDisabledProviders(Boolean includeDisabledProviders) {
            this.instance.includeDisabledProviders = includeDisabledProviders;
            return this;
        }

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

    /**
     * Create a builder with a shallow copy of this instance.
     */
    public BoxSetInfoRemoteSearchQuery.Builder toBuilder() {
        return new BoxSetInfoRemoteSearchQuery.Builder().searchInfo(getSearchInfo()).itemId(getItemId())
                .searchProviderName(getSearchProviderName()).includeDisabledProviders(getIncludeDisabledProviders());
    }
}
