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

import com.fasterxml.jackson.annotation.JsonProperty;

/**
 * Class GroupInfoDto.
 */
@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "OpenAPI Generator")
public class GroupInfoDto {
    public static final String JSON_PROPERTY_GROUP_ID = "GroupId";
    private @org.eclipse.jdt.annotation.Nullable UUID groupId;

    public static final String JSON_PROPERTY_GROUP_NAME = "GroupName";
    private @org.eclipse.jdt.annotation.Nullable String groupName;

    public static final String JSON_PROPERTY_STATE = "State";
    private @org.eclipse.jdt.annotation.Nullable GroupStateType state;

    public static final String JSON_PROPERTY_PARTICIPANTS = "Participants";
    private @org.eclipse.jdt.annotation.Nullable List<String> participants = new ArrayList<>();

    public static final String JSON_PROPERTY_LAST_UPDATED_AT = "LastUpdatedAt";
    private @org.eclipse.jdt.annotation.Nullable OffsetDateTime lastUpdatedAt;

    public GroupInfoDto() {
    }

    public GroupInfoDto groupId(@org.eclipse.jdt.annotation.Nullable UUID groupId) {
        this.groupId = groupId;
        return this;
    }

    /**
     * Gets the group identifier.
     * 
     * @return groupId
     */
    @JsonProperty(value = JSON_PROPERTY_GROUP_ID)
    public @org.eclipse.jdt.annotation.Nullable UUID getGroupId() {
        return groupId;
    }

    @JsonProperty(value = JSON_PROPERTY_GROUP_ID)
    public void setGroupId(@org.eclipse.jdt.annotation.Nullable UUID groupId) {
        this.groupId = groupId;
    }

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

    /**
     * Gets the group name.
     * 
     * @return groupName
     */
    @JsonProperty(value = JSON_PROPERTY_GROUP_NAME)
    public @org.eclipse.jdt.annotation.Nullable String getGroupName() {
        return groupName;
    }

    @JsonProperty(value = JSON_PROPERTY_GROUP_NAME)
    public void setGroupName(@org.eclipse.jdt.annotation.Nullable String groupName) {
        this.groupName = groupName;
    }

    public GroupInfoDto state(@org.eclipse.jdt.annotation.Nullable GroupStateType state) {
        this.state = state;
        return this;
    }

    /**
     * Gets the group state.
     * 
     * @return state
     */
    @JsonProperty(value = JSON_PROPERTY_STATE)
    public @org.eclipse.jdt.annotation.Nullable GroupStateType getState() {
        return state;
    }

    @JsonProperty(value = JSON_PROPERTY_STATE)
    public void setState(@org.eclipse.jdt.annotation.Nullable GroupStateType state) {
        this.state = state;
    }

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

    public GroupInfoDto addParticipantsItem(String participantsItem) {
        if (this.participants == null) {
            this.participants = new ArrayList<>();
        }
        this.participants.add(participantsItem);
        return this;
    }

    /**
     * Gets the participants.
     * 
     * @return participants
     */
    @JsonProperty(value = JSON_PROPERTY_PARTICIPANTS)
    public @org.eclipse.jdt.annotation.Nullable List<String> getParticipants() {
        return participants;
    }

    @JsonProperty(value = JSON_PROPERTY_PARTICIPANTS)
    public void setParticipants(@org.eclipse.jdt.annotation.Nullable List<String> participants) {
        this.participants = participants;
    }

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

    /**
     * Gets the date when this DTO has been created.
     * 
     * @return lastUpdatedAt
     */
    @JsonProperty(value = JSON_PROPERTY_LAST_UPDATED_AT)
    public @org.eclipse.jdt.annotation.Nullable OffsetDateTime getLastUpdatedAt() {
        return lastUpdatedAt;
    }

    @JsonProperty(value = JSON_PROPERTY_LAST_UPDATED_AT)
    public void setLastUpdatedAt(@org.eclipse.jdt.annotation.Nullable OffsetDateTime lastUpdatedAt) {
        this.lastUpdatedAt = lastUpdatedAt;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        GroupInfoDto groupInfoDto = (GroupInfoDto) o;
        return Objects.equals(this.groupId, groupInfoDto.groupId)
                && Objects.equals(this.groupName, groupInfoDto.groupName)
                && Objects.equals(this.state, groupInfoDto.state)
                && Objects.equals(this.participants, groupInfoDto.participants)
                && Objects.equals(this.lastUpdatedAt, groupInfoDto.lastUpdatedAt);
    }

    @Override
    public int hashCode() {
        return Objects.hash(groupId, groupName, state, participants, lastUpdatedAt);
    }

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

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

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

        // add `Participants` to the URL query string
        if (getParticipants() != null) {
            for (int i = 0; i < getParticipants().size(); i++) {
                try {
                    joiner.add(String.format(java.util.Locale.ROOT, "%sParticipants%s%s=%s", prefix, suffix,
                            "".equals(suffix) ? ""
                                    : String.format(java.util.Locale.ROOT, "%s%d%s", containerPrefix, i,
                                            containerSuffix),
                            URLEncoder.encode(String.valueOf(getParticipants().get(i)), "UTF-8").replaceAll("\\+",
                                    "%20")));
                } catch (UnsupportedEncodingException e) {
                    // Should never happen, UTF-8 is always supported
                    throw new RuntimeException(e);
                }
            }
        }

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

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

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

        public GroupInfoDto.Builder groupId(UUID groupId) {
            this.instance.groupId = groupId;
            return this;
        }

        public GroupInfoDto.Builder groupName(String groupName) {
            this.instance.groupName = groupName;
            return this;
        }

        public GroupInfoDto.Builder state(GroupStateType state) {
            this.instance.state = state;
            return this;
        }

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

        public GroupInfoDto.Builder lastUpdatedAt(OffsetDateTime lastUpdatedAt) {
            this.instance.lastUpdatedAt = lastUpdatedAt;
            return this;
        }

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

    /**
     * Create a builder with a shallow copy of this instance.
     */
    public GroupInfoDto.Builder toBuilder() {
        return new GroupInfoDto.Builder().groupId(getGroupId()).groupName(getGroupName()).state(getState())
                .participants(getParticipants()).lastUpdatedAt(getLastUpdatedAt());
    }
}
