/*
 * 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.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.StringJoiner;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
 * Class CultureDto.
 */
@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "OpenAPI Generator")
public class CultureDto {
    public static final String JSON_PROPERTY_NAME = "Name";
    private @org.eclipse.jdt.annotation.Nullable String name;

    public static final String JSON_PROPERTY_DISPLAY_NAME = "DisplayName";
    private @org.eclipse.jdt.annotation.Nullable String displayName;

    public static final String JSON_PROPERTY_TWO_LETTER_I_S_O_LANGUAGE_NAME = "TwoLetterISOLanguageName";
    private @org.eclipse.jdt.annotation.Nullable String twoLetterISOLanguageName;

    public static final String JSON_PROPERTY_THREE_LETTER_I_S_O_LANGUAGE_NAME = "ThreeLetterISOLanguageName";
    private @org.eclipse.jdt.annotation.Nullable String threeLetterISOLanguageName;

    public static final String JSON_PROPERTY_THREE_LETTER_I_S_O_LANGUAGE_NAMES = "ThreeLetterISOLanguageNames";
    private @org.eclipse.jdt.annotation.Nullable List<String> threeLetterISOLanguageNames = new ArrayList<>();

    public CultureDto() {
    }

    /**
     * Constructor with only readonly parameters
     */
    @JsonCreator
    public CultureDto(
            @JsonProperty(value = JSON_PROPERTY_THREE_LETTER_I_S_O_LANGUAGE_NAME) String threeLetterISOLanguageName) {
        this();
        this.threeLetterISOLanguageName = threeLetterISOLanguageName;
    }

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

    /**
     * Gets 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 CultureDto displayName(@org.eclipse.jdt.annotation.Nullable String displayName) {
        this.displayName = displayName;
        return this;
    }

    /**
     * Gets the display name.
     * 
     * @return displayName
     */
    @JsonProperty(value = JSON_PROPERTY_DISPLAY_NAME)
    public @org.eclipse.jdt.annotation.Nullable String getDisplayName() {
        return displayName;
    }

    @JsonProperty(value = JSON_PROPERTY_DISPLAY_NAME)
    public void setDisplayName(@org.eclipse.jdt.annotation.Nullable String displayName) {
        this.displayName = displayName;
    }

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

    /**
     * Gets the name of the two letter ISO language.
     * 
     * @return twoLetterISOLanguageName
     */
    @JsonProperty(value = JSON_PROPERTY_TWO_LETTER_I_S_O_LANGUAGE_NAME)
    public @org.eclipse.jdt.annotation.Nullable String getTwoLetterISOLanguageName() {
        return twoLetterISOLanguageName;
    }

    @JsonProperty(value = JSON_PROPERTY_TWO_LETTER_I_S_O_LANGUAGE_NAME)
    public void setTwoLetterISOLanguageName(@org.eclipse.jdt.annotation.Nullable String twoLetterISOLanguageName) {
        this.twoLetterISOLanguageName = twoLetterISOLanguageName;
    }

    /**
     * Gets the name of the three letter ISO language.
     * 
     * @return threeLetterISOLanguageName
     */
    @JsonProperty(value = JSON_PROPERTY_THREE_LETTER_I_S_O_LANGUAGE_NAME)
    public @org.eclipse.jdt.annotation.Nullable String getThreeLetterISOLanguageName() {
        return threeLetterISOLanguageName;
    }

    public CultureDto threeLetterISOLanguageNames(
            @org.eclipse.jdt.annotation.Nullable List<String> threeLetterISOLanguageNames) {
        this.threeLetterISOLanguageNames = threeLetterISOLanguageNames;
        return this;
    }

    public CultureDto addThreeLetterISOLanguageNamesItem(String threeLetterISOLanguageNamesItem) {
        if (this.threeLetterISOLanguageNames == null) {
            this.threeLetterISOLanguageNames = new ArrayList<>();
        }
        this.threeLetterISOLanguageNames.add(threeLetterISOLanguageNamesItem);
        return this;
    }

    /**
     * Get threeLetterISOLanguageNames
     * 
     * @return threeLetterISOLanguageNames
     */
    @JsonProperty(value = JSON_PROPERTY_THREE_LETTER_I_S_O_LANGUAGE_NAMES)
    public @org.eclipse.jdt.annotation.Nullable List<String> getThreeLetterISOLanguageNames() {
        return threeLetterISOLanguageNames;
    }

    @JsonProperty(value = JSON_PROPERTY_THREE_LETTER_I_S_O_LANGUAGE_NAMES)
    public void setThreeLetterISOLanguageNames(
            @org.eclipse.jdt.annotation.Nullable List<String> threeLetterISOLanguageNames) {
        this.threeLetterISOLanguageNames = threeLetterISOLanguageNames;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        CultureDto cultureDto = (CultureDto) o;
        return Objects.equals(this.name, cultureDto.name) && Objects.equals(this.displayName, cultureDto.displayName)
                && Objects.equals(this.twoLetterISOLanguageName, cultureDto.twoLetterISOLanguageName)
                && Objects.equals(this.threeLetterISOLanguageName, cultureDto.threeLetterISOLanguageName)
                && Objects.equals(this.threeLetterISOLanguageNames, cultureDto.threeLetterISOLanguageNames);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, displayName, twoLetterISOLanguageName, threeLetterISOLanguageName,
                threeLetterISOLanguageNames);
    }

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

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

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

        // add `ThreeLetterISOLanguageNames` to the URL query string
        if (getThreeLetterISOLanguageNames() != null) {
            for (int i = 0; i < getThreeLetterISOLanguageNames().size(); i++) {
                try {
                    joiner.add(
                            String.format(java.util.Locale.ROOT, "%sThreeLetterISOLanguageNames%s%s=%s", prefix, suffix,
                                    "".equals(suffix) ? ""
                                            : String.format(java.util.Locale.ROOT, "%s%d%s", containerPrefix, i,
                                                    containerSuffix),
                                    URLEncoder.encode(String.valueOf(getThreeLetterISOLanguageNames().get(i)), "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 CultureDto instance;

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

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

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

        public CultureDto.Builder displayName(String displayName) {
            this.instance.displayName = displayName;
            return this;
        }

        public CultureDto.Builder twoLetterISOLanguageName(String twoLetterISOLanguageName) {
            this.instance.twoLetterISOLanguageName = twoLetterISOLanguageName;
            return this;
        }

        public CultureDto.Builder threeLetterISOLanguageName(String threeLetterISOLanguageName) {
            this.instance.threeLetterISOLanguageName = threeLetterISOLanguageName;
            return this;
        }

        public CultureDto.Builder threeLetterISOLanguageNames(List<String> threeLetterISOLanguageNames) {
            this.instance.threeLetterISOLanguageNames = threeLetterISOLanguageNames;
            return this;
        }

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

    /**
     * Create a builder with a shallow copy of this instance.
     */
    public CultureDto.Builder toBuilder() {
        return new CultureDto.Builder().name(getName()).displayName(getDisplayName())
                .twoLetterISOLanguageName(getTwoLetterISOLanguageName())
                .threeLetterISOLanguageName(getThreeLetterISOLanguageName())
                .threeLetterISOLanguageNames(getThreeLetterISOLanguageNames());
    }
}
