/*
 * 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 java.util.UUID;

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

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

    public static final String JSON_PROPERTY_DATA = "Data";
    private @org.eclipse.jdt.annotation.Nullable String data;

    public static final String JSON_PROPERTY_TYPE = "Type";
    private @org.eclipse.jdt.annotation.Nullable GroupUpdateType type = GroupUpdateType.USER_JOINED;

    public SyncPlayUserJoinedUpdate() {
    }

    /**
     * Constructor with only readonly parameters
     */
    @JsonCreator
    public SyncPlayUserJoinedUpdate(@JsonProperty(value = JSON_PROPERTY_GROUP_ID) UUID groupId,
            @JsonProperty(value = JSON_PROPERTY_DATA) String data,
            @JsonProperty(value = JSON_PROPERTY_TYPE) GroupUpdateType type) {
        this();
        this.groupId = groupId;
        this.data = data;
        this.type = type;
    }

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

    /**
     * Gets the update data.
     * 
     * @return data
     */
    @JsonProperty(value = JSON_PROPERTY_DATA)
    public @org.eclipse.jdt.annotation.Nullable String getData() {
        return data;
    }

    /**
     * Enum GroupUpdateType.
     * 
     * @return type
     */
    @JsonProperty(value = JSON_PROPERTY_TYPE)
    public @org.eclipse.jdt.annotation.Nullable GroupUpdateType getType() {
        return type;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        SyncPlayUserJoinedUpdate syncPlayUserJoinedUpdate = (SyncPlayUserJoinedUpdate) o;
        return Objects.equals(this.groupId, syncPlayUserJoinedUpdate.groupId)
                && Objects.equals(this.data, syncPlayUserJoinedUpdate.data)
                && Objects.equals(this.type, syncPlayUserJoinedUpdate.type);
    }

    @Override
    public int hashCode() {
        return Objects.hash(groupId, data, type);
    }

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

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

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

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

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

        public SyncPlayUserJoinedUpdate.Builder data(String data) {
            this.instance.data = data;
            return this;
        }

        public SyncPlayUserJoinedUpdate.Builder type(GroupUpdateType type) {
            this.instance.type = type;
            return this;
        }

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

    /**
     * Create a builder with a shallow copy of this instance.
     */
    public SyncPlayUserJoinedUpdate.Builder toBuilder() {
        return new SyncPlayUserJoinedUpdate.Builder().groupId(getGroupId()).data(getData()).type(getType());
    }
}
