/*
 * 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 TaskExecutionInfo.
 */
@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "OpenAPI Generator")
public class TaskResult {
    public static final String JSON_PROPERTY_START_TIME_UTC = "StartTimeUtc";
    private @org.eclipse.jdt.annotation.Nullable OffsetDateTime startTimeUtc;

    public static final String JSON_PROPERTY_END_TIME_UTC = "EndTimeUtc";
    private @org.eclipse.jdt.annotation.Nullable OffsetDateTime endTimeUtc;

    public static final String JSON_PROPERTY_STATUS = "Status";
    private @org.eclipse.jdt.annotation.Nullable TaskCompletionStatus status;

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

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

    public static final String JSON_PROPERTY_ID = "Id";
    private @org.eclipse.jdt.annotation.Nullable String id;

    public static final String JSON_PROPERTY_ERROR_MESSAGE = "ErrorMessage";
    private @org.eclipse.jdt.annotation.Nullable String errorMessage;

    public static final String JSON_PROPERTY_LONG_ERROR_MESSAGE = "LongErrorMessage";
    private @org.eclipse.jdt.annotation.Nullable String longErrorMessage;

    public TaskResult() {
    }

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

    /**
     * Gets or sets the start time UTC.
     * 
     * @return startTimeUtc
     */
    @JsonProperty(value = JSON_PROPERTY_START_TIME_UTC)
    public @org.eclipse.jdt.annotation.Nullable OffsetDateTime getStartTimeUtc() {
        return startTimeUtc;
    }

    @JsonProperty(value = JSON_PROPERTY_START_TIME_UTC)
    public void setStartTimeUtc(@org.eclipse.jdt.annotation.Nullable OffsetDateTime startTimeUtc) {
        this.startTimeUtc = startTimeUtc;
    }

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

    /**
     * Gets or sets the end time UTC.
     * 
     * @return endTimeUtc
     */
    @JsonProperty(value = JSON_PROPERTY_END_TIME_UTC)
    public @org.eclipse.jdt.annotation.Nullable OffsetDateTime getEndTimeUtc() {
        return endTimeUtc;
    }

    @JsonProperty(value = JSON_PROPERTY_END_TIME_UTC)
    public void setEndTimeUtc(@org.eclipse.jdt.annotation.Nullable OffsetDateTime endTimeUtc) {
        this.endTimeUtc = endTimeUtc;
    }

    public TaskResult status(@org.eclipse.jdt.annotation.Nullable TaskCompletionStatus status) {
        this.status = status;
        return this;
    }

    /**
     * Gets or sets the status.
     * 
     * @return status
     */
    @JsonProperty(value = JSON_PROPERTY_STATUS)
    public @org.eclipse.jdt.annotation.Nullable TaskCompletionStatus getStatus() {
        return status;
    }

    @JsonProperty(value = JSON_PROPERTY_STATUS)
    public void setStatus(@org.eclipse.jdt.annotation.Nullable TaskCompletionStatus status) {
        this.status = status;
    }

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

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

    @JsonProperty(value = JSON_PROPERTY_ID)
    public void setId(@org.eclipse.jdt.annotation.Nullable String id) {
        this.id = id;
    }

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

    /**
     * Gets or sets the error message.
     * 
     * @return errorMessage
     */
    @JsonProperty(value = JSON_PROPERTY_ERROR_MESSAGE)
    public @org.eclipse.jdt.annotation.Nullable String getErrorMessage() {
        return errorMessage;
    }

    @JsonProperty(value = JSON_PROPERTY_ERROR_MESSAGE)
    public void setErrorMessage(@org.eclipse.jdt.annotation.Nullable String errorMessage) {
        this.errorMessage = errorMessage;
    }

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

    /**
     * Gets or sets the long error message.
     * 
     * @return longErrorMessage
     */
    @JsonProperty(value = JSON_PROPERTY_LONG_ERROR_MESSAGE)
    public @org.eclipse.jdt.annotation.Nullable String getLongErrorMessage() {
        return longErrorMessage;
    }

    @JsonProperty(value = JSON_PROPERTY_LONG_ERROR_MESSAGE)
    public void setLongErrorMessage(@org.eclipse.jdt.annotation.Nullable String longErrorMessage) {
        this.longErrorMessage = longErrorMessage;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        TaskResult taskResult = (TaskResult) o;
        return Objects.equals(this.startTimeUtc, taskResult.startTimeUtc)
                && Objects.equals(this.endTimeUtc, taskResult.endTimeUtc)
                && Objects.equals(this.status, taskResult.status) && Objects.equals(this.name, taskResult.name)
                && Objects.equals(this.key, taskResult.key) && Objects.equals(this.id, taskResult.id)
                && Objects.equals(this.errorMessage, taskResult.errorMessage)
                && Objects.equals(this.longErrorMessage, taskResult.longErrorMessage);
    }

    @Override
    public int hashCode() {
        return Objects.hash(startTimeUtc, endTimeUtc, status, name, key, id, errorMessage, longErrorMessage);
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("class TaskResult {\n");
        sb.append("    startTimeUtc: ").append(toIndentedString(startTimeUtc)).append("\n");
        sb.append("    endTimeUtc: ").append(toIndentedString(endTimeUtc)).append("\n");
        sb.append("    status: ").append(toIndentedString(status)).append("\n");
        sb.append("    name: ").append(toIndentedString(name)).append("\n");
        sb.append("    key: ").append(toIndentedString(key)).append("\n");
        sb.append("    id: ").append(toIndentedString(id)).append("\n");
        sb.append("    errorMessage: ").append(toIndentedString(errorMessage)).append("\n");
        sb.append("    longErrorMessage: ").append(toIndentedString(longErrorMessage)).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 `StartTimeUtc` to the URL query string
        if (getStartTimeUtc() != null) {
            try {
                joiner.add(String.format(java.util.Locale.ROOT, "%sStartTimeUtc%s=%s", prefix, suffix,
                        URLEncoder.encode(String.valueOf(getStartTimeUtc()), "UTF-8").replaceAll("\\+", "%20")));
            } catch (UnsupportedEncodingException e) {
                // Should never happen, UTF-8 is always supported
                throw new RuntimeException(e);
            }
        }

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

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

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

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

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

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

        public TaskResult.Builder startTimeUtc(OffsetDateTime startTimeUtc) {
            this.instance.startTimeUtc = startTimeUtc;
            return this;
        }

        public TaskResult.Builder endTimeUtc(OffsetDateTime endTimeUtc) {
            this.instance.endTimeUtc = endTimeUtc;
            return this;
        }

        public TaskResult.Builder status(TaskCompletionStatus status) {
            this.instance.status = status;
            return this;
        }

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

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

        public TaskResult.Builder id(String id) {
            this.instance.id = id;
            return this;
        }

        public TaskResult.Builder errorMessage(String errorMessage) {
            this.instance.errorMessage = errorMessage;
            return this;
        }

        public TaskResult.Builder longErrorMessage(String longErrorMessage) {
            this.instance.longErrorMessage = longErrorMessage;
            return this;
        }

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

    /**
     * Create a builder with a shallow copy of this instance.
     */
    public TaskResult.Builder toBuilder() {
        return new TaskResult.Builder().startTimeUtc(getStartTimeUtc()).endTimeUtc(getEndTimeUtc()).status(getStatus())
                .name(getName()).key(getKey()).id(getId()).errorMessage(getErrorMessage())
                .longErrorMessage(getLongErrorMessage());
    }
}
