// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.resourcemanager.providerhub.models;

import com.azure.core.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;

/** The ExtendedErrorInfo model. */
@Fluent
public final class ExtendedErrorInfo {
    /*
     * The code property.
     */
    @JsonProperty(value = "code")
    private String code;

    /*
     * The target property.
     */
    @JsonProperty(value = "target")
    private String target;

    /*
     * The message property.
     */
    @JsonProperty(value = "message")
    private String message;

    /*
     * The details property.
     */
    @JsonProperty(value = "details")
    private List<ExtendedErrorInfo> details;

    /*
     * The additionalInfo property.
     */
    @JsonProperty(value = "additionalInfo")
    private List<TypedErrorInfo> additionalInfo;

    /** Creates an instance of ExtendedErrorInfo class. */
    public ExtendedErrorInfo() {
    }

    /**
     * Get the code property: The code property.
     *
     * @return the code value.
     */
    public String code() {
        return this.code;
    }

    /**
     * Set the code property: The code property.
     *
     * @param code the code value to set.
     * @return the ExtendedErrorInfo object itself.
     */
    public ExtendedErrorInfo withCode(String code) {
        this.code = code;
        return this;
    }

    /**
     * Get the target property: The target property.
     *
     * @return the target value.
     */
    public String target() {
        return this.target;
    }

    /**
     * Set the target property: The target property.
     *
     * @param target the target value to set.
     * @return the ExtendedErrorInfo object itself.
     */
    public ExtendedErrorInfo withTarget(String target) {
        this.target = target;
        return this;
    }

    /**
     * Get the message property: The message property.
     *
     * @return the message value.
     */
    public String message() {
        return this.message;
    }

    /**
     * Set the message property: The message property.
     *
     * @param message the message value to set.
     * @return the ExtendedErrorInfo object itself.
     */
    public ExtendedErrorInfo withMessage(String message) {
        this.message = message;
        return this;
    }

    /**
     * Get the details property: The details property.
     *
     * @return the details value.
     */
    public List<ExtendedErrorInfo> details() {
        return this.details;
    }

    /**
     * Set the details property: The details property.
     *
     * @param details the details value to set.
     * @return the ExtendedErrorInfo object itself.
     */
    public ExtendedErrorInfo withDetails(List<ExtendedErrorInfo> details) {
        this.details = details;
        return this;
    }

    /**
     * Get the additionalInfo property: The additionalInfo property.
     *
     * @return the additionalInfo value.
     */
    public List<TypedErrorInfo> additionalInfo() {
        return this.additionalInfo;
    }

    /**
     * Set the additionalInfo property: The additionalInfo property.
     *
     * @param additionalInfo the additionalInfo value to set.
     * @return the ExtendedErrorInfo object itself.
     */
    public ExtendedErrorInfo withAdditionalInfo(List<TypedErrorInfo> additionalInfo) {
        this.additionalInfo = additionalInfo;
        return this;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (details() != null) {
            details().forEach(e -> e.validate());
        }
        if (additionalInfo() != null) {
            additionalInfo().forEach(e -> e.validate());
        }
    }
}
