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

package com.azure.resourcemanager.databox.models;

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

/** The requirements to validate customer address where the device needs to be shipped. */
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "validationType")
@JsonTypeName("ValidateAddress")
@Fluent
public final class ValidateAddress extends ValidationInputRequest {
    /*
     * Shipping address of the customer.
     */
    @JsonProperty(value = "shippingAddress", required = true)
    private ShippingAddress shippingAddress;

    /*
     * Device type to be used for the job.
     */
    @JsonProperty(value = "deviceType", required = true)
    private SkuName deviceType;

    /*
     * Preferences related to the shipment logistics of the sku.
     */
    @JsonProperty(value = "transportPreferences")
    private TransportPreferences transportPreferences;

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

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

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

    /**
     * Get the deviceType property: Device type to be used for the job.
     *
     * @return the deviceType value.
     */
    public SkuName deviceType() {
        return this.deviceType;
    }

    /**
     * Set the deviceType property: Device type to be used for the job.
     *
     * @param deviceType the deviceType value to set.
     * @return the ValidateAddress object itself.
     */
    public ValidateAddress withDeviceType(SkuName deviceType) {
        this.deviceType = deviceType;
        return this;
    }

    /**
     * Get the transportPreferences property: Preferences related to the shipment logistics of the sku.
     *
     * @return the transportPreferences value.
     */
    public TransportPreferences transportPreferences() {
        return this.transportPreferences;
    }

    /**
     * Set the transportPreferences property: Preferences related to the shipment logistics of the sku.
     *
     * @param transportPreferences the transportPreferences value to set.
     * @return the ValidateAddress object itself.
     */
    public ValidateAddress withTransportPreferences(TransportPreferences transportPreferences) {
        this.transportPreferences = transportPreferences;
        return this;
    }

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

    private static final ClientLogger LOGGER = new ClientLogger(ValidateAddress.class);
}
