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

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

import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
import com.azure.resourcemanager.managednetworkfabric.models.AnnotationResource;
import com.azure.resourcemanager.managednetworkfabric.models.IpPrefixPropertiesIpPrefixRulesItem;
import com.azure.resourcemanager.managednetworkfabric.models.ProvisioningState;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;

/** IpPrefixProperties define the resource properties. */
@Fluent
public final class IpPrefixProperties extends AnnotationResource {
    /*
     * IpPrefix contains the list of IP PrefixRules objects.
     */
    @JsonProperty(value = "ipPrefixRules", required = true)
    private List<IpPrefixPropertiesIpPrefixRulesItem> ipPrefixRules;

    /*
     * Gets the provisioning state of the resource.
     */
    @JsonProperty(value = "provisioningState", access = JsonProperty.Access.WRITE_ONLY)
    private ProvisioningState provisioningState;

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

    /**
     * Get the ipPrefixRules property: IpPrefix contains the list of IP PrefixRules objects.
     *
     * @return the ipPrefixRules value.
     */
    public List<IpPrefixPropertiesIpPrefixRulesItem> ipPrefixRules() {
        return this.ipPrefixRules;
    }

    /**
     * Set the ipPrefixRules property: IpPrefix contains the list of IP PrefixRules objects.
     *
     * @param ipPrefixRules the ipPrefixRules value to set.
     * @return the IpPrefixProperties object itself.
     */
    public IpPrefixProperties withIpPrefixRules(List<IpPrefixPropertiesIpPrefixRulesItem> ipPrefixRules) {
        this.ipPrefixRules = ipPrefixRules;
        return this;
    }

    /**
     * Get the provisioningState property: Gets the provisioning state of the resource.
     *
     * @return the provisioningState value.
     */
    public ProvisioningState provisioningState() {
        return this.provisioningState;
    }

    /** {@inheritDoc} */
    @Override
    public IpPrefixProperties withAnnotation(String annotation) {
        super.withAnnotation(annotation);
        return this;
    }

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

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