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

import com.fasterxml.jackson.annotation.JsonProperty;

/**
 * Class ChapterInfo.
 */
@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "OpenAPI Generator")
public class ChapterInfo {
    public static final String JSON_PROPERTY_START_POSITION_TICKS = "StartPositionTicks";
    private @org.eclipse.jdt.annotation.Nullable Long startPositionTicks;

    public static final String JSON_PROPERTY_NAME = "Name";
    private @org.eclipse.jdt.annotation.Nullable String name;

    public static final String JSON_PROPERTY_IMAGE_PATH = "ImagePath";
    private @org.eclipse.jdt.annotation.Nullable String imagePath;

    public static final String JSON_PROPERTY_IMAGE_DATE_MODIFIED = "ImageDateModified";
    private @org.eclipse.jdt.annotation.Nullable OffsetDateTime imageDateModified;

    public static final String JSON_PROPERTY_IMAGE_TAG = "ImageTag";
    private @org.eclipse.jdt.annotation.Nullable String imageTag;

    public ChapterInfo() {
    }

    public ChapterInfo startPositionTicks(@org.eclipse.jdt.annotation.Nullable Long startPositionTicks) {
        this.startPositionTicks = startPositionTicks;
        return this;
    }

    /**
     * Gets or sets the start position ticks.
     * 
     * @return startPositionTicks
     */
    @JsonProperty(value = JSON_PROPERTY_START_POSITION_TICKS)
    public @org.eclipse.jdt.annotation.Nullable Long getStartPositionTicks() {
        return startPositionTicks;
    }

    @JsonProperty(value = JSON_PROPERTY_START_POSITION_TICKS)
    public void setStartPositionTicks(@org.eclipse.jdt.annotation.Nullable Long startPositionTicks) {
        this.startPositionTicks = startPositionTicks;
    }

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

    /**
     * Gets or sets the image path.
     * 
     * @return imagePath
     */
    @JsonProperty(value = JSON_PROPERTY_IMAGE_PATH)
    public @org.eclipse.jdt.annotation.Nullable String getImagePath() {
        return imagePath;
    }

    @JsonProperty(value = JSON_PROPERTY_IMAGE_PATH)
    public void setImagePath(@org.eclipse.jdt.annotation.Nullable String imagePath) {
        this.imagePath = imagePath;
    }

    public ChapterInfo imageDateModified(@org.eclipse.jdt.annotation.Nullable OffsetDateTime imageDateModified) {
        this.imageDateModified = imageDateModified;
        return this;
    }

    /**
     * Get imageDateModified
     * 
     * @return imageDateModified
     */
    @JsonProperty(value = JSON_PROPERTY_IMAGE_DATE_MODIFIED)
    public @org.eclipse.jdt.annotation.Nullable OffsetDateTime getImageDateModified() {
        return imageDateModified;
    }

    @JsonProperty(value = JSON_PROPERTY_IMAGE_DATE_MODIFIED)
    public void setImageDateModified(@org.eclipse.jdt.annotation.Nullable OffsetDateTime imageDateModified) {
        this.imageDateModified = imageDateModified;
    }

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

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

    @JsonProperty(value = JSON_PROPERTY_IMAGE_TAG)
    public void setImageTag(@org.eclipse.jdt.annotation.Nullable String imageTag) {
        this.imageTag = imageTag;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        ChapterInfo chapterInfo = (ChapterInfo) o;
        return Objects.equals(this.startPositionTicks, chapterInfo.startPositionTicks)
                && Objects.equals(this.name, chapterInfo.name) && Objects.equals(this.imagePath, chapterInfo.imagePath)
                && Objects.equals(this.imageDateModified, chapterInfo.imageDateModified)
                && Objects.equals(this.imageTag, chapterInfo.imageTag);
    }

    @Override
    public int hashCode() {
        return Objects.hash(startPositionTicks, name, imagePath, imageDateModified, imageTag);
    }

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

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

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

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

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

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

        public ChapterInfo.Builder startPositionTicks(Long startPositionTicks) {
            this.instance.startPositionTicks = startPositionTicks;
            return this;
        }

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

        public ChapterInfo.Builder imagePath(String imagePath) {
            this.instance.imagePath = imagePath;
            return this;
        }

        public ChapterInfo.Builder imageDateModified(OffsetDateTime imageDateModified) {
            this.instance.imageDateModified = imageDateModified;
            return this;
        }

        public ChapterInfo.Builder imageTag(String imageTag) {
            this.instance.imageTag = imageTag;
            return this;
        }

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

    /**
     * Create a builder with a shallow copy of this instance.
     */
    public ChapterInfo.Builder toBuilder() {
        return new ChapterInfo.Builder().startPositionTicks(getStartPositionTicks()).name(getName())
                .imagePath(getImagePath()).imageDateModified(getImageDateModified()).imageTag(getImageTag());
    }
}
