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

/**
 * ProfileCondition
 */
@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "OpenAPI Generator")
public class ProfileCondition {
    public static final String JSON_PROPERTY_CONDITION = "Condition";
    private @org.eclipse.jdt.annotation.Nullable ProfileConditionType condition;

    public static final String JSON_PROPERTY_PROPERTY = "Property";
    private @org.eclipse.jdt.annotation.Nullable ProfileConditionValue property;

    public static final String JSON_PROPERTY_VALUE = "Value";
    private @org.eclipse.jdt.annotation.Nullable String value;

    public static final String JSON_PROPERTY_IS_REQUIRED = "IsRequired";
    private @org.eclipse.jdt.annotation.Nullable Boolean isRequired;

    public ProfileCondition() {
    }

    public ProfileCondition condition(@org.eclipse.jdt.annotation.Nullable ProfileConditionType condition) {
        this.condition = condition;
        return this;
    }

    /**
     * Get condition
     * 
     * @return condition
     */
    @JsonProperty(value = JSON_PROPERTY_CONDITION)
    public @org.eclipse.jdt.annotation.Nullable ProfileConditionType getCondition() {
        return condition;
    }

    @JsonProperty(value = JSON_PROPERTY_CONDITION)
    public void setCondition(@org.eclipse.jdt.annotation.Nullable ProfileConditionType condition) {
        this.condition = condition;
    }

    public ProfileCondition property(@org.eclipse.jdt.annotation.Nullable ProfileConditionValue property) {
        this.property = property;
        return this;
    }

    /**
     * Get property
     * 
     * @return property
     */
    @JsonProperty(value = JSON_PROPERTY_PROPERTY)
    public @org.eclipse.jdt.annotation.Nullable ProfileConditionValue getProperty() {
        return property;
    }

    @JsonProperty(value = JSON_PROPERTY_PROPERTY)
    public void setProperty(@org.eclipse.jdt.annotation.Nullable ProfileConditionValue property) {
        this.property = property;
    }

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

    /**
     * Get value
     * 
     * @return value
     */
    @JsonProperty(value = JSON_PROPERTY_VALUE)
    public @org.eclipse.jdt.annotation.Nullable String getValue() {
        return value;
    }

    @JsonProperty(value = JSON_PROPERTY_VALUE)
    public void setValue(@org.eclipse.jdt.annotation.Nullable String value) {
        this.value = value;
    }

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

    /**
     * Get isRequired
     * 
     * @return isRequired
     */
    @JsonProperty(value = JSON_PROPERTY_IS_REQUIRED)
    public @org.eclipse.jdt.annotation.Nullable Boolean getIsRequired() {
        return isRequired;
    }

    @JsonProperty(value = JSON_PROPERTY_IS_REQUIRED)
    public void setIsRequired(@org.eclipse.jdt.annotation.Nullable Boolean isRequired) {
        this.isRequired = isRequired;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        ProfileCondition profileCondition = (ProfileCondition) o;
        return Objects.equals(this.condition, profileCondition.condition)
                && Objects.equals(this.property, profileCondition.property)
                && Objects.equals(this.value, profileCondition.value)
                && Objects.equals(this.isRequired, profileCondition.isRequired);
    }

    @Override
    public int hashCode() {
        return Objects.hash(condition, property, value, isRequired);
    }

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

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

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

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

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

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

        public ProfileCondition.Builder condition(ProfileConditionType condition) {
            this.instance.condition = condition;
            return this;
        }

        public ProfileCondition.Builder property(ProfileConditionValue property) {
            this.instance.property = property;
            return this;
        }

        public ProfileCondition.Builder value(String value) {
            this.instance.value = value;
            return this;
        }

        public ProfileCondition.Builder isRequired(Boolean isRequired) {
            this.instance.isRequired = isRequired;
            return this;
        }

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

    /**
     * Create a builder with a shallow copy of this instance.
     */
    public ProfileCondition.Builder toBuilder() {
        return new ProfileCondition.Builder().condition(getCondition()).property(getProperty()).value(getValue())
                .isRequired(getIsRequired());
    }
}
