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

package com.azure.resourcemanager.edgeorder.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
import com.azure.resourcemanager.edgeorder.fluent.models.AddressProperties;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;

/** Address details for an order item. */
@Fluent
public final class AddressDetails {
    @JsonIgnore private final ClientLogger logger = new ClientLogger(AddressDetails.class);

    /*
     * Customer address and contact details. It should be address resource
     */
    @JsonProperty(value = "forwardAddress", required = true)
    private AddressProperties forwardAddress;

    /*
     * Return shipping address
     */
    @JsonProperty(value = "returnAddress", access = JsonProperty.Access.WRITE_ONLY)
    private AddressProperties returnAddress;

    /**
     * Get the forwardAddress property: Customer address and contact details. It should be address resource.
     *
     * @return the forwardAddress value.
     */
    public AddressProperties forwardAddress() {
        return this.forwardAddress;
    }

    /**
     * Set the forwardAddress property: Customer address and contact details. It should be address resource.
     *
     * @param forwardAddress the forwardAddress value to set.
     * @return the AddressDetails object itself.
     */
    public AddressDetails withForwardAddress(AddressProperties forwardAddress) {
        this.forwardAddress = forwardAddress;
        return this;
    }

    /**
     * Get the returnAddress property: Return shipping address.
     *
     * @return the returnAddress value.
     */
    public AddressProperties returnAddress() {
        return this.returnAddress;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (forwardAddress() == null) {
            throw logger
                .logExceptionAsError(
                    new IllegalArgumentException("Missing required property forwardAddress in model AddressDetails"));
        } else {
            forwardAddress().validate();
        }
        if (returnAddress() != null) {
            returnAddress().validate();
        }
    }
}
