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

/**
 * This is used by the api to get information about a item user data.
 */
@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "OpenAPI Generator")
public class UpdateUserItemDataDto {
    public static final String JSON_PROPERTY_RATING = "Rating";
    private @org.eclipse.jdt.annotation.Nullable Double rating;

    public static final String JSON_PROPERTY_PLAYED_PERCENTAGE = "PlayedPercentage";
    private @org.eclipse.jdt.annotation.Nullable Double playedPercentage;

    public static final String JSON_PROPERTY_UNPLAYED_ITEM_COUNT = "UnplayedItemCount";
    private @org.eclipse.jdt.annotation.Nullable Integer unplayedItemCount;

    public static final String JSON_PROPERTY_PLAYBACK_POSITION_TICKS = "PlaybackPositionTicks";
    private @org.eclipse.jdt.annotation.Nullable Long playbackPositionTicks;

    public static final String JSON_PROPERTY_PLAY_COUNT = "PlayCount";
    private @org.eclipse.jdt.annotation.Nullable Integer playCount;

    public static final String JSON_PROPERTY_IS_FAVORITE = "IsFavorite";
    private @org.eclipse.jdt.annotation.Nullable Boolean isFavorite;

    public static final String JSON_PROPERTY_LIKES = "Likes";
    private @org.eclipse.jdt.annotation.Nullable Boolean likes;

    public static final String JSON_PROPERTY_LAST_PLAYED_DATE = "LastPlayedDate";
    private @org.eclipse.jdt.annotation.Nullable OffsetDateTime lastPlayedDate;

    public static final String JSON_PROPERTY_PLAYED = "Played";
    private @org.eclipse.jdt.annotation.Nullable Boolean played;

    public static final String JSON_PROPERTY_KEY = "Key";
    private @org.eclipse.jdt.annotation.Nullable String key;

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

    public UpdateUserItemDataDto() {
    }

    public UpdateUserItemDataDto rating(@org.eclipse.jdt.annotation.Nullable Double rating) {
        this.rating = rating;
        return this;
    }

    /**
     * Gets or sets the rating.
     * 
     * @return rating
     */
    @JsonProperty(value = JSON_PROPERTY_RATING)
    public @org.eclipse.jdt.annotation.Nullable Double getRating() {
        return rating;
    }

    @JsonProperty(value = JSON_PROPERTY_RATING)
    public void setRating(@org.eclipse.jdt.annotation.Nullable Double rating) {
        this.rating = rating;
    }

    public UpdateUserItemDataDto playedPercentage(@org.eclipse.jdt.annotation.Nullable Double playedPercentage) {
        this.playedPercentage = playedPercentage;
        return this;
    }

    /**
     * Gets or sets the played percentage.
     * 
     * @return playedPercentage
     */
    @JsonProperty(value = JSON_PROPERTY_PLAYED_PERCENTAGE)
    public @org.eclipse.jdt.annotation.Nullable Double getPlayedPercentage() {
        return playedPercentage;
    }

    @JsonProperty(value = JSON_PROPERTY_PLAYED_PERCENTAGE)
    public void setPlayedPercentage(@org.eclipse.jdt.annotation.Nullable Double playedPercentage) {
        this.playedPercentage = playedPercentage;
    }

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

    /**
     * Gets or sets the unplayed item count.
     * 
     * @return unplayedItemCount
     */
    @JsonProperty(value = JSON_PROPERTY_UNPLAYED_ITEM_COUNT)
    public @org.eclipse.jdt.annotation.Nullable Integer getUnplayedItemCount() {
        return unplayedItemCount;
    }

    @JsonProperty(value = JSON_PROPERTY_UNPLAYED_ITEM_COUNT)
    public void setUnplayedItemCount(@org.eclipse.jdt.annotation.Nullable Integer unplayedItemCount) {
        this.unplayedItemCount = unplayedItemCount;
    }

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

    /**
     * Gets or sets the playback position ticks.
     * 
     * @return playbackPositionTicks
     */
    @JsonProperty(value = JSON_PROPERTY_PLAYBACK_POSITION_TICKS)
    public @org.eclipse.jdt.annotation.Nullable Long getPlaybackPositionTicks() {
        return playbackPositionTicks;
    }

    @JsonProperty(value = JSON_PROPERTY_PLAYBACK_POSITION_TICKS)
    public void setPlaybackPositionTicks(@org.eclipse.jdt.annotation.Nullable Long playbackPositionTicks) {
        this.playbackPositionTicks = playbackPositionTicks;
    }

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

    /**
     * Gets or sets the play count.
     * 
     * @return playCount
     */
    @JsonProperty(value = JSON_PROPERTY_PLAY_COUNT)
    public @org.eclipse.jdt.annotation.Nullable Integer getPlayCount() {
        return playCount;
    }

    @JsonProperty(value = JSON_PROPERTY_PLAY_COUNT)
    public void setPlayCount(@org.eclipse.jdt.annotation.Nullable Integer playCount) {
        this.playCount = playCount;
    }

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

    /**
     * Gets or sets a value indicating whether this instance is favorite.
     * 
     * @return isFavorite
     */
    @JsonProperty(value = JSON_PROPERTY_IS_FAVORITE)
    public @org.eclipse.jdt.annotation.Nullable Boolean getIsFavorite() {
        return isFavorite;
    }

    @JsonProperty(value = JSON_PROPERTY_IS_FAVORITE)
    public void setIsFavorite(@org.eclipse.jdt.annotation.Nullable Boolean isFavorite) {
        this.isFavorite = isFavorite;
    }

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

    /**
     * Gets or sets a value indicating whether this MediaBrowser.Model.Dto.UpdateUserItemDataDto is likes.
     * 
     * @return likes
     */
    @JsonProperty(value = JSON_PROPERTY_LIKES)
    public @org.eclipse.jdt.annotation.Nullable Boolean getLikes() {
        return likes;
    }

    @JsonProperty(value = JSON_PROPERTY_LIKES)
    public void setLikes(@org.eclipse.jdt.annotation.Nullable Boolean likes) {
        this.likes = likes;
    }

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

    /**
     * Gets or sets the last played date.
     * 
     * @return lastPlayedDate
     */
    @JsonProperty(value = JSON_PROPERTY_LAST_PLAYED_DATE)
    public @org.eclipse.jdt.annotation.Nullable OffsetDateTime getLastPlayedDate() {
        return lastPlayedDate;
    }

    @JsonProperty(value = JSON_PROPERTY_LAST_PLAYED_DATE)
    public void setLastPlayedDate(@org.eclipse.jdt.annotation.Nullable OffsetDateTime lastPlayedDate) {
        this.lastPlayedDate = lastPlayedDate;
    }

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

    /**
     * Gets or sets a value indicating whether this MediaBrowser.Model.Dto.UserItemDataDto is played.
     * 
     * @return played
     */
    @JsonProperty(value = JSON_PROPERTY_PLAYED)
    public @org.eclipse.jdt.annotation.Nullable Boolean getPlayed() {
        return played;
    }

    @JsonProperty(value = JSON_PROPERTY_PLAYED)
    public void setPlayed(@org.eclipse.jdt.annotation.Nullable Boolean played) {
        this.played = played;
    }

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

    /**
     * Gets or sets the key.
     * 
     * @return key
     */
    @JsonProperty(value = JSON_PROPERTY_KEY)
    public @org.eclipse.jdt.annotation.Nullable String getKey() {
        return key;
    }

    @JsonProperty(value = JSON_PROPERTY_KEY)
    public void setKey(@org.eclipse.jdt.annotation.Nullable String key) {
        this.key = key;
    }

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

    /**
     * Gets or sets the item identifier.
     * 
     * @return itemId
     */
    @JsonProperty(value = JSON_PROPERTY_ITEM_ID)
    public @org.eclipse.jdt.annotation.Nullable String getItemId() {
        return itemId;
    }

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

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        UpdateUserItemDataDto updateUserItemDataDto = (UpdateUserItemDataDto) o;
        return Objects.equals(this.rating, updateUserItemDataDto.rating)
                && Objects.equals(this.playedPercentage, updateUserItemDataDto.playedPercentage)
                && Objects.equals(this.unplayedItemCount, updateUserItemDataDto.unplayedItemCount)
                && Objects.equals(this.playbackPositionTicks, updateUserItemDataDto.playbackPositionTicks)
                && Objects.equals(this.playCount, updateUserItemDataDto.playCount)
                && Objects.equals(this.isFavorite, updateUserItemDataDto.isFavorite)
                && Objects.equals(this.likes, updateUserItemDataDto.likes)
                && Objects.equals(this.lastPlayedDate, updateUserItemDataDto.lastPlayedDate)
                && Objects.equals(this.played, updateUserItemDataDto.played)
                && Objects.equals(this.key, updateUserItemDataDto.key)
                && Objects.equals(this.itemId, updateUserItemDataDto.itemId);
    }

    @Override
    public int hashCode() {
        return Objects.hash(rating, playedPercentage, unplayedItemCount, playbackPositionTicks, playCount, isFavorite,
                likes, lastPlayedDate, played, key, itemId);
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("class UpdateUserItemDataDto {\n");
        sb.append("    rating: ").append(toIndentedString(rating)).append("\n");
        sb.append("    playedPercentage: ").append(toIndentedString(playedPercentage)).append("\n");
        sb.append("    unplayedItemCount: ").append(toIndentedString(unplayedItemCount)).append("\n");
        sb.append("    playbackPositionTicks: ").append(toIndentedString(playbackPositionTicks)).append("\n");
        sb.append("    playCount: ").append(toIndentedString(playCount)).append("\n");
        sb.append("    isFavorite: ").append(toIndentedString(isFavorite)).append("\n");
        sb.append("    likes: ").append(toIndentedString(likes)).append("\n");
        sb.append("    lastPlayedDate: ").append(toIndentedString(lastPlayedDate)).append("\n");
        sb.append("    played: ").append(toIndentedString(played)).append("\n");
        sb.append("    key: ").append(toIndentedString(key)).append("\n");
        sb.append("    itemId: ").append(toIndentedString(itemId)).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 `Rating` to the URL query string
        if (getRating() != null) {
            try {
                joiner.add(String.format(java.util.Locale.ROOT, "%sRating%s=%s", prefix, suffix,
                        URLEncoder.encode(String.valueOf(getRating()), "UTF-8").replaceAll("\\+", "%20")));
            } catch (UnsupportedEncodingException e) {
                // Should never happen, UTF-8 is always supported
                throw new RuntimeException(e);
            }
        }

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

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

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

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

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

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

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

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

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

        // 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);
            }
        }

        return joiner.toString();
    }

    public static class Builder {

        private UpdateUserItemDataDto instance;

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

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

        public UpdateUserItemDataDto.Builder rating(Double rating) {
            this.instance.rating = rating;
            return this;
        }

        public UpdateUserItemDataDto.Builder playedPercentage(Double playedPercentage) {
            this.instance.playedPercentage = playedPercentage;
            return this;
        }

        public UpdateUserItemDataDto.Builder unplayedItemCount(Integer unplayedItemCount) {
            this.instance.unplayedItemCount = unplayedItemCount;
            return this;
        }

        public UpdateUserItemDataDto.Builder playbackPositionTicks(Long playbackPositionTicks) {
            this.instance.playbackPositionTicks = playbackPositionTicks;
            return this;
        }

        public UpdateUserItemDataDto.Builder playCount(Integer playCount) {
            this.instance.playCount = playCount;
            return this;
        }

        public UpdateUserItemDataDto.Builder isFavorite(Boolean isFavorite) {
            this.instance.isFavorite = isFavorite;
            return this;
        }

        public UpdateUserItemDataDto.Builder likes(Boolean likes) {
            this.instance.likes = likes;
            return this;
        }

        public UpdateUserItemDataDto.Builder lastPlayedDate(OffsetDateTime lastPlayedDate) {
            this.instance.lastPlayedDate = lastPlayedDate;
            return this;
        }

        public UpdateUserItemDataDto.Builder played(Boolean played) {
            this.instance.played = played;
            return this;
        }

        public UpdateUserItemDataDto.Builder key(String key) {
            this.instance.key = key;
            return this;
        }

        public UpdateUserItemDataDto.Builder itemId(String itemId) {
            this.instance.itemId = itemId;
            return this;
        }

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

    /**
     * Create a builder with a shallow copy of this instance.
     */
    public UpdateUserItemDataDto.Builder toBuilder() {
        return new UpdateUserItemDataDto.Builder().rating(getRating()).playedPercentage(getPlayedPercentage())
                .unplayedItemCount(getUnplayedItemCount()).playbackPositionTicks(getPlaybackPositionTicks())
                .playCount(getPlayCount()).isFavorite(getIsFavorite()).likes(getLikes())
                .lastPlayedDate(getLastPlayedDate()).played(getPlayed()).key(getKey()).itemId(getItemId());
    }
}
