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

package com.azure.resourcemanager.policyinsights.models;

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

/** The restrictions that will be placed on a field in the resource by policy. */
@Fluent
public final class FieldRestrictions {
    /*
     * The name of the field. This can be a top-level property like 'name' or 'type' or an Azure Policy field alias.
     */
    @JsonProperty(value = "field", access = JsonProperty.Access.WRITE_ONLY)
    private String field;

    /*
     * The restrictions placed on that field by policy.
     */
    @JsonProperty(value = "restrictions")
    private List<FieldRestriction> restrictions;

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

    /**
     * Get the field property: The name of the field. This can be a top-level property like 'name' or 'type' or an Azure
     * Policy field alias.
     *
     * @return the field value.
     */
    public String field() {
        return this.field;
    }

    /**
     * Get the restrictions property: The restrictions placed on that field by policy.
     *
     * @return the restrictions value.
     */
    public List<FieldRestriction> restrictions() {
        return this.restrictions;
    }

    /**
     * Set the restrictions property: The restrictions placed on that field by policy.
     *
     * @param restrictions the restrictions value to set.
     * @return the FieldRestrictions object itself.
     */
    public FieldRestrictions withRestrictions(List<FieldRestriction> restrictions) {
        this.restrictions = restrictions;
        return this;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (restrictions() != null) {
            restrictions().forEach(e -> e.validate());
        }
    }
}
