// 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.fluent.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
import com.azure.resourcemanager.edgeorder.models.AddressValidationStatus;
import com.azure.resourcemanager.edgeorder.models.ContactDetails;
import com.azure.resourcemanager.edgeorder.models.ShippingAddress;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;

/** Address Properties. */
@Fluent
public final class AddressProperties {
    @JsonIgnore private final ClientLogger logger = new ClientLogger(AddressProperties.class);

    /*
     * Shipping details for the address
     */
    @JsonProperty(value = "shippingAddress")
    private ShippingAddress shippingAddress;

    /*
     * Contact details for the address
     */
    @JsonProperty(value = "contactDetails", required = true)
    private ContactDetails contactDetails;

    /*
     * Status of address validation
     */
    @JsonProperty(value = "addressValidationStatus", access = JsonProperty.Access.WRITE_ONLY)
    private AddressValidationStatus addressValidationStatus;

    /**
     * Get the shippingAddress property: Shipping details for the address.
     *
     * @return the shippingAddress value.
     */
    public ShippingAddress shippingAddress() {
        return this.shippingAddress;
    }

    /**
     * Set the shippingAddress property: Shipping details for the address.
     *
     * @param shippingAddress the shippingAddress value to set.
     * @return the AddressProperties object itself.
     */
    public AddressProperties withShippingAddress(ShippingAddress shippingAddress) {
        this.shippingAddress = shippingAddress;
        return this;
    }

    /**
     * Get the contactDetails property: Contact details for the address.
     *
     * @return the contactDetails value.
     */
    public ContactDetails contactDetails() {
        return this.contactDetails;
    }

    /**
     * Set the contactDetails property: Contact details for the address.
     *
     * @param contactDetails the contactDetails value to set.
     * @return the AddressProperties object itself.
     */
    public AddressProperties withContactDetails(ContactDetails contactDetails) {
        this.contactDetails = contactDetails;
        return this;
    }

    /**
     * Get the addressValidationStatus property: Status of address validation.
     *
     * @return the addressValidationStatus value.
     */
    public AddressValidationStatus addressValidationStatus() {
        return this.addressValidationStatus;
    }

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