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

package com.azure.resourcemanager.securityinsights.models;

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

/**
 * Dependencies for the content item, what other content items it requires to work. Can describe more complex
 * dependencies using a recursive/nested structure. For a single dependency an id/kind/version can be supplied or
 * operator/criteria for complex dependencies.
 */
@Fluent
public final class MetadataDependencies {
    /*
     * Id of the content item we depend on
     */
    @JsonProperty(value = "contentId")
    private String contentId;

    /*
     * Type of the content item we depend on
     */
    @JsonProperty(value = "kind")
    private Kind kind;

    /*
     * Version of the the content item we depend on.  Can be blank, * or missing to indicate any version fulfills the
     * dependency.  If version does not match our defined numeric format then an exact match is required.
     */
    @JsonProperty(value = "version")
    private String version;

    /*
     * Name of the content item
     */
    @JsonProperty(value = "name")
    private String name;

    /*
     * Operator used for list of dependencies in criteria array.
     */
    @JsonProperty(value = "operator")
    private Operator operator;

    /*
     * This is the list of dependencies we must fulfill, according to the AND/OR operator
     */
    @JsonProperty(value = "criteria")
    private List<MetadataDependencies> criteria;

    /**
     * Get the contentId property: Id of the content item we depend on.
     *
     * @return the contentId value.
     */
    public String contentId() {
        return this.contentId;
    }

    /**
     * Set the contentId property: Id of the content item we depend on.
     *
     * @param contentId the contentId value to set.
     * @return the MetadataDependencies object itself.
     */
    public MetadataDependencies withContentId(String contentId) {
        this.contentId = contentId;
        return this;
    }

    /**
     * Get the kind property: Type of the content item we depend on.
     *
     * @return the kind value.
     */
    public Kind kind() {
        return this.kind;
    }

    /**
     * Set the kind property: Type of the content item we depend on.
     *
     * @param kind the kind value to set.
     * @return the MetadataDependencies object itself.
     */
    public MetadataDependencies withKind(Kind kind) {
        this.kind = kind;
        return this;
    }

    /**
     * Get the version property: Version of the the content item we depend on. Can be blank, * or missing to indicate
     * any version fulfills the dependency. If version does not match our defined numeric format then an exact match is
     * required.
     *
     * @return the version value.
     */
    public String version() {
        return this.version;
    }

    /**
     * Set the version property: Version of the the content item we depend on. Can be blank, * or missing to indicate
     * any version fulfills the dependency. If version does not match our defined numeric format then an exact match is
     * required.
     *
     * @param version the version value to set.
     * @return the MetadataDependencies object itself.
     */
    public MetadataDependencies withVersion(String version) {
        this.version = version;
        return this;
    }

    /**
     * Get the name property: Name of the content item.
     *
     * @return the name value.
     */
    public String name() {
        return this.name;
    }

    /**
     * Set the name property: Name of the content item.
     *
     * @param name the name value to set.
     * @return the MetadataDependencies object itself.
     */
    public MetadataDependencies withName(String name) {
        this.name = name;
        return this;
    }

    /**
     * Get the operator property: Operator used for list of dependencies in criteria array.
     *
     * @return the operator value.
     */
    public Operator operator() {
        return this.operator;
    }

    /**
     * Set the operator property: Operator used for list of dependencies in criteria array.
     *
     * @param operator the operator value to set.
     * @return the MetadataDependencies object itself.
     */
    public MetadataDependencies withOperator(Operator operator) {
        this.operator = operator;
        return this;
    }

    /**
     * Get the criteria property: This is the list of dependencies we must fulfill, according to the AND/OR operator.
     *
     * @return the criteria value.
     */
    public List<MetadataDependencies> criteria() {
        return this.criteria;
    }

    /**
     * Set the criteria property: This is the list of dependencies we must fulfill, according to the AND/OR operator.
     *
     * @param criteria the criteria value to set.
     * @return the MetadataDependencies object itself.
     */
    public MetadataDependencies withCriteria(List<MetadataDependencies> criteria) {
        this.criteria = criteria;
        return this;
    }

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