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

package com.azure.resourcemanager.mobilenetwork.models;

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

/** Per-slice settings. */
@Fluent
public final class SliceConfiguration {
    /*
     * A reference to the slice that these settings apply to. The slice must be in the same location as the SIM policy.
     */
    @JsonProperty(value = "slice", required = true)
    private SliceResourceId slice;

    /*
     * The default data network to use if the UE does not explicitly specify it. Configuration for this object must
     * exist in the `dataNetworkConfigurations` map. The data network must be in the same location as the SIM policy.
     */
    @JsonProperty(value = "defaultDataNetwork", required = true)
    private DataNetworkResourceId defaultDataNetwork;

    /*
     * The allowed data networks and the settings to use for them. The list must not contain duplicate items and must
     * contain at least one item.
     */
    @JsonProperty(value = "dataNetworkConfigurations", required = true)
    private List<DataNetworkConfiguration> dataNetworkConfigurations;

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

    /**
     * Get the slice property: A reference to the slice that these settings apply to. The slice must be in the same
     * location as the SIM policy.
     *
     * @return the slice value.
     */
    public SliceResourceId slice() {
        return this.slice;
    }

    /**
     * Set the slice property: A reference to the slice that these settings apply to. The slice must be in the same
     * location as the SIM policy.
     *
     * @param slice the slice value to set.
     * @return the SliceConfiguration object itself.
     */
    public SliceConfiguration withSlice(SliceResourceId slice) {
        this.slice = slice;
        return this;
    }

    /**
     * Get the defaultDataNetwork property: The default data network to use if the UE does not explicitly specify it.
     * Configuration for this object must exist in the `dataNetworkConfigurations` map. The data network must be in the
     * same location as the SIM policy.
     *
     * @return the defaultDataNetwork value.
     */
    public DataNetworkResourceId defaultDataNetwork() {
        return this.defaultDataNetwork;
    }

    /**
     * Set the defaultDataNetwork property: The default data network to use if the UE does not explicitly specify it.
     * Configuration for this object must exist in the `dataNetworkConfigurations` map. The data network must be in the
     * same location as the SIM policy.
     *
     * @param defaultDataNetwork the defaultDataNetwork value to set.
     * @return the SliceConfiguration object itself.
     */
    public SliceConfiguration withDefaultDataNetwork(DataNetworkResourceId defaultDataNetwork) {
        this.defaultDataNetwork = defaultDataNetwork;
        return this;
    }

    /**
     * Get the dataNetworkConfigurations property: The allowed data networks and the settings to use for them. The list
     * must not contain duplicate items and must contain at least one item.
     *
     * @return the dataNetworkConfigurations value.
     */
    public List<DataNetworkConfiguration> dataNetworkConfigurations() {
        return this.dataNetworkConfigurations;
    }

    /**
     * Set the dataNetworkConfigurations property: The allowed data networks and the settings to use for them. The list
     * must not contain duplicate items and must contain at least one item.
     *
     * @param dataNetworkConfigurations the dataNetworkConfigurations value to set.
     * @return the SliceConfiguration object itself.
     */
    public SliceConfiguration withDataNetworkConfigurations(List<DataNetworkConfiguration> dataNetworkConfigurations) {
        this.dataNetworkConfigurations = dataNetworkConfigurations;
        return this;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (slice() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException("Missing required property slice in model SliceConfiguration"));
        } else {
            slice().validate();
        }
        if (defaultDataNetwork() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property defaultDataNetwork in model SliceConfiguration"));
        } else {
            defaultDataNetwork().validate();
        }
        if (dataNetworkConfigurations() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property dataNetworkConfigurations in model SliceConfiguration"));
        } else {
            dataNetworkConfigurations().forEach(e -> e.validate());
        }
    }

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