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

package com.azure.resourcemanager.authorization.fluent.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;

/** Active Directory OData error information. */
@Fluent
public final class OdataError {
    @JsonIgnore private final ClientLogger logger = new ClientLogger(OdataError.class);

    /*
     * Error code.
     */
    @JsonProperty(value = "code")
    private String code;

    /*
     * Error Message.
     */
    @JsonProperty(value = "message")
    private ErrorMessage innerMessage;

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

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

    /**
     * Get the innerMessage property: Error Message.
     *
     * @return the innerMessage value.
     */
    private ErrorMessage innerMessage() {
        return this.innerMessage;
    }

    /**
     * Get the message property: Error message value.
     *
     * @return the message value.
     */
    public String message() {
        return this.innerMessage() == null ? null : this.innerMessage().message();
    }

    /**
     * Set the message property: Error message value.
     *
     * @param message the message value to set.
     * @return the OdataError object itself.
     */
    public OdataError withMessage(String message) {
        if (this.innerMessage() == null) {
            this.innerMessage = new ErrorMessage();
        }
        this.innerMessage().withMessage(message);
        return this;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (innerMessage() != null) {
            innerMessage().validate();
        }
    }
}
