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

/**
 * A class representing an parental rating score.
 */
@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "OpenAPI Generator")
public class ParentalRatingScore {
    public static final String JSON_PROPERTY_SCORE = "score";
    private @org.eclipse.jdt.annotation.Nullable Integer score;

    public static final String JSON_PROPERTY_SUB_SCORE = "subScore";
    private @org.eclipse.jdt.annotation.Nullable Integer subScore;

    public ParentalRatingScore() {
    }

    public ParentalRatingScore score(@org.eclipse.jdt.annotation.Nullable Integer score) {
        this.score = score;
        return this;
    }

    /**
     * Gets or sets the score.
     * 
     * @return score
     */
    @JsonProperty(value = JSON_PROPERTY_SCORE)
    public @org.eclipse.jdt.annotation.Nullable Integer getScore() {
        return score;
    }

    @JsonProperty(value = JSON_PROPERTY_SCORE)
    public void setScore(@org.eclipse.jdt.annotation.Nullable Integer score) {
        this.score = score;
    }

    public ParentalRatingScore subScore(@org.eclipse.jdt.annotation.Nullable Integer subScore) {
        this.subScore = subScore;
        return this;
    }

    /**
     * Gets or sets the sub score.
     * 
     * @return subScore
     */
    @JsonProperty(value = JSON_PROPERTY_SUB_SCORE)
    public @org.eclipse.jdt.annotation.Nullable Integer getSubScore() {
        return subScore;
    }

    @JsonProperty(value = JSON_PROPERTY_SUB_SCORE)
    public void setSubScore(@org.eclipse.jdt.annotation.Nullable Integer subScore) {
        this.subScore = subScore;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        ParentalRatingScore parentalRatingScore = (ParentalRatingScore) o;
        return Objects.equals(this.score, parentalRatingScore.score)
                && Objects.equals(this.subScore, parentalRatingScore.subScore);
    }

    @Override
    public int hashCode() {
        return Objects.hash(score, subScore);
    }

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

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

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

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

        public ParentalRatingScore.Builder score(Integer score) {
            this.instance.score = score;
            return this;
        }

        public ParentalRatingScore.Builder subScore(Integer subScore) {
            this.instance.subScore = subScore;
            return this;
        }

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

    /**
     * Create a builder with a shallow copy of this instance.
     */
    public ParentalRatingScore.Builder toBuilder() {
        return new ParentalRatingScore.Builder().score(getScore()).subScore(getSubScore());
    }
}
