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

package com.azure.resourcemanager.logic.models;

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

/** The swagger schema. */
@Fluent
public final class SwaggerSchema {
    /*
     * The reference.
     */
    @JsonProperty(value = "ref")
    private String ref;

    /*
     * The type
     */
    @JsonProperty(value = "type")
    private SwaggerSchemaType type;

    /*
     * The title.
     */
    @JsonProperty(value = "title")
    private String title;

    /*
     * The items schema.
     */
    @JsonProperty(value = "items")
    private SwaggerSchema items;

    /*
     * The object properties
     */
    @JsonProperty(value = "properties")
    @JsonInclude(value = JsonInclude.Include.NON_NULL, content = JsonInclude.Include.ALWAYS)
    private Map<String, SwaggerSchema> properties;

    /*
     * The additional properties.
     */
    @JsonProperty(value = "additionalProperties")
    private Object additionalProperties;

    /*
     * The object required properties.
     */
    @JsonProperty(value = "required")
    private List<String> required;

    /*
     * The maximum number of allowed properties.
     */
    @JsonProperty(value = "maxProperties")
    private Integer maxProperties;

    /*
     * The minimum number of allowed properties.
     */
    @JsonProperty(value = "minProperties")
    private Integer minProperties;

    /*
     * The schemas which must pass validation when this schema is used.
     */
    @JsonProperty(value = "allOf")
    private List<SwaggerSchema> allOf;

    /*
     * The discriminator.
     */
    @JsonProperty(value = "discriminator")
    private String discriminator;

    /*
     * Indicates whether this property must be present in the a request.
     */
    @JsonProperty(value = "readOnly")
    private Boolean readOnly;

    /*
     * The xml representation format for a property.
     */
    @JsonProperty(value = "xml")
    private SwaggerXml xml;

    /*
     * The external documentation.
     */
    @JsonProperty(value = "externalDocs")
    private SwaggerExternalDocumentation externalDocs;

    /*
     * The example value.
     */
    @JsonProperty(value = "example")
    private Object example;

    /*
     * Indicates the notification url extension. If this is set, the property's value should be a callback url for a
     * webhook.
     */
    @JsonProperty(value = "notificationUrlExtension")
    private Boolean notificationUrlExtension;

    /*
     * The dynamic schema configuration.
     */
    @JsonProperty(value = "dynamicSchemaOld")
    private SwaggerCustomDynamicSchema dynamicSchemaOld;

    /*
     * The dynamic schema configuration.
     */
    @JsonProperty(value = "dynamicSchemaNew")
    private SwaggerCustomDynamicProperties dynamicSchemaNew;

    /*
     * The dynamic list.
     */
    @JsonProperty(value = "dynamicListNew")
    private SwaggerCustomDynamicList dynamicListNew;

    /*
     * The dynamic values tree configuration.
     */
    @JsonProperty(value = "dynamicTree")
    private SwaggerCustomDynamicTree dynamicTree;

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

    /**
     * Get the ref property: The reference.
     *
     * @return the ref value.
     */
    public String ref() {
        return this.ref;
    }

    /**
     * Set the ref property: The reference.
     *
     * @param ref the ref value to set.
     * @return the SwaggerSchema object itself.
     */
    public SwaggerSchema withRef(String ref) {
        this.ref = ref;
        return this;
    }

    /**
     * Get the type property: The type.
     *
     * @return the type value.
     */
    public SwaggerSchemaType type() {
        return this.type;
    }

    /**
     * Set the type property: The type.
     *
     * @param type the type value to set.
     * @return the SwaggerSchema object itself.
     */
    public SwaggerSchema withType(SwaggerSchemaType type) {
        this.type = type;
        return this;
    }

    /**
     * Get the title property: The title.
     *
     * @return the title value.
     */
    public String title() {
        return this.title;
    }

    /**
     * Set the title property: The title.
     *
     * @param title the title value to set.
     * @return the SwaggerSchema object itself.
     */
    public SwaggerSchema withTitle(String title) {
        this.title = title;
        return this;
    }

    /**
     * Get the items property: The items schema.
     *
     * @return the items value.
     */
    public SwaggerSchema items() {
        return this.items;
    }

    /**
     * Set the items property: The items schema.
     *
     * @param items the items value to set.
     * @return the SwaggerSchema object itself.
     */
    public SwaggerSchema withItems(SwaggerSchema items) {
        this.items = items;
        return this;
    }

    /**
     * Get the properties property: The object properties.
     *
     * @return the properties value.
     */
    public Map<String, SwaggerSchema> properties() {
        return this.properties;
    }

    /**
     * Set the properties property: The object properties.
     *
     * @param properties the properties value to set.
     * @return the SwaggerSchema object itself.
     */
    public SwaggerSchema withProperties(Map<String, SwaggerSchema> properties) {
        this.properties = properties;
        return this;
    }

    /**
     * Get the additionalProperties property: The additional properties.
     *
     * @return the additionalProperties value.
     */
    public Object additionalProperties() {
        return this.additionalProperties;
    }

    /**
     * Set the additionalProperties property: The additional properties.
     *
     * @param additionalProperties the additionalProperties value to set.
     * @return the SwaggerSchema object itself.
     */
    public SwaggerSchema withAdditionalProperties(Object additionalProperties) {
        this.additionalProperties = additionalProperties;
        return this;
    }

    /**
     * Get the required property: The object required properties.
     *
     * @return the required value.
     */
    public List<String> required() {
        return this.required;
    }

    /**
     * Set the required property: The object required properties.
     *
     * @param required the required value to set.
     * @return the SwaggerSchema object itself.
     */
    public SwaggerSchema withRequired(List<String> required) {
        this.required = required;
        return this;
    }

    /**
     * Get the maxProperties property: The maximum number of allowed properties.
     *
     * @return the maxProperties value.
     */
    public Integer maxProperties() {
        return this.maxProperties;
    }

    /**
     * Set the maxProperties property: The maximum number of allowed properties.
     *
     * @param maxProperties the maxProperties value to set.
     * @return the SwaggerSchema object itself.
     */
    public SwaggerSchema withMaxProperties(Integer maxProperties) {
        this.maxProperties = maxProperties;
        return this;
    }

    /**
     * Get the minProperties property: The minimum number of allowed properties.
     *
     * @return the minProperties value.
     */
    public Integer minProperties() {
        return this.minProperties;
    }

    /**
     * Set the minProperties property: The minimum number of allowed properties.
     *
     * @param minProperties the minProperties value to set.
     * @return the SwaggerSchema object itself.
     */
    public SwaggerSchema withMinProperties(Integer minProperties) {
        this.minProperties = minProperties;
        return this;
    }

    /**
     * Get the allOf property: The schemas which must pass validation when this schema is used.
     *
     * @return the allOf value.
     */
    public List<SwaggerSchema> allOf() {
        return this.allOf;
    }

    /**
     * Set the allOf property: The schemas which must pass validation when this schema is used.
     *
     * @param allOf the allOf value to set.
     * @return the SwaggerSchema object itself.
     */
    public SwaggerSchema withAllOf(List<SwaggerSchema> allOf) {
        this.allOf = allOf;
        return this;
    }

    /**
     * Get the discriminator property: The discriminator.
     *
     * @return the discriminator value.
     */
    public String discriminator() {
        return this.discriminator;
    }

    /**
     * Set the discriminator property: The discriminator.
     *
     * @param discriminator the discriminator value to set.
     * @return the SwaggerSchema object itself.
     */
    public SwaggerSchema withDiscriminator(String discriminator) {
        this.discriminator = discriminator;
        return this;
    }

    /**
     * Get the readOnly property: Indicates whether this property must be present in the a request.
     *
     * @return the readOnly value.
     */
    public Boolean readOnly() {
        return this.readOnly;
    }

    /**
     * Set the readOnly property: Indicates whether this property must be present in the a request.
     *
     * @param readOnly the readOnly value to set.
     * @return the SwaggerSchema object itself.
     */
    public SwaggerSchema withReadOnly(Boolean readOnly) {
        this.readOnly = readOnly;
        return this;
    }

    /**
     * Get the xml property: The xml representation format for a property.
     *
     * @return the xml value.
     */
    public SwaggerXml xml() {
        return this.xml;
    }

    /**
     * Set the xml property: The xml representation format for a property.
     *
     * @param xml the xml value to set.
     * @return the SwaggerSchema object itself.
     */
    public SwaggerSchema withXml(SwaggerXml xml) {
        this.xml = xml;
        return this;
    }

    /**
     * Get the externalDocs property: The external documentation.
     *
     * @return the externalDocs value.
     */
    public SwaggerExternalDocumentation externalDocs() {
        return this.externalDocs;
    }

    /**
     * Set the externalDocs property: The external documentation.
     *
     * @param externalDocs the externalDocs value to set.
     * @return the SwaggerSchema object itself.
     */
    public SwaggerSchema withExternalDocs(SwaggerExternalDocumentation externalDocs) {
        this.externalDocs = externalDocs;
        return this;
    }

    /**
     * Get the example property: The example value.
     *
     * @return the example value.
     */
    public Object example() {
        return this.example;
    }

    /**
     * Set the example property: The example value.
     *
     * @param example the example value to set.
     * @return the SwaggerSchema object itself.
     */
    public SwaggerSchema withExample(Object example) {
        this.example = example;
        return this;
    }

    /**
     * Get the notificationUrlExtension property: Indicates the notification url extension. If this is set, the
     * property's value should be a callback url for a webhook.
     *
     * @return the notificationUrlExtension value.
     */
    public Boolean notificationUrlExtension() {
        return this.notificationUrlExtension;
    }

    /**
     * Set the notificationUrlExtension property: Indicates the notification url extension. If this is set, the
     * property's value should be a callback url for a webhook.
     *
     * @param notificationUrlExtension the notificationUrlExtension value to set.
     * @return the SwaggerSchema object itself.
     */
    public SwaggerSchema withNotificationUrlExtension(Boolean notificationUrlExtension) {
        this.notificationUrlExtension = notificationUrlExtension;
        return this;
    }

    /**
     * Get the dynamicSchemaOld property: The dynamic schema configuration.
     *
     * @return the dynamicSchemaOld value.
     */
    public SwaggerCustomDynamicSchema dynamicSchemaOld() {
        return this.dynamicSchemaOld;
    }

    /**
     * Set the dynamicSchemaOld property: The dynamic schema configuration.
     *
     * @param dynamicSchemaOld the dynamicSchemaOld value to set.
     * @return the SwaggerSchema object itself.
     */
    public SwaggerSchema withDynamicSchemaOld(SwaggerCustomDynamicSchema dynamicSchemaOld) {
        this.dynamicSchemaOld = dynamicSchemaOld;
        return this;
    }

    /**
     * Get the dynamicSchemaNew property: The dynamic schema configuration.
     *
     * @return the dynamicSchemaNew value.
     */
    public SwaggerCustomDynamicProperties dynamicSchemaNew() {
        return this.dynamicSchemaNew;
    }

    /**
     * Set the dynamicSchemaNew property: The dynamic schema configuration.
     *
     * @param dynamicSchemaNew the dynamicSchemaNew value to set.
     * @return the SwaggerSchema object itself.
     */
    public SwaggerSchema withDynamicSchemaNew(SwaggerCustomDynamicProperties dynamicSchemaNew) {
        this.dynamicSchemaNew = dynamicSchemaNew;
        return this;
    }

    /**
     * Get the dynamicListNew property: The dynamic list.
     *
     * @return the dynamicListNew value.
     */
    public SwaggerCustomDynamicList dynamicListNew() {
        return this.dynamicListNew;
    }

    /**
     * Set the dynamicListNew property: The dynamic list.
     *
     * @param dynamicListNew the dynamicListNew value to set.
     * @return the SwaggerSchema object itself.
     */
    public SwaggerSchema withDynamicListNew(SwaggerCustomDynamicList dynamicListNew) {
        this.dynamicListNew = dynamicListNew;
        return this;
    }

    /**
     * Get the dynamicTree property: The dynamic values tree configuration.
     *
     * @return the dynamicTree value.
     */
    public SwaggerCustomDynamicTree dynamicTree() {
        return this.dynamicTree;
    }

    /**
     * Set the dynamicTree property: The dynamic values tree configuration.
     *
     * @param dynamicTree the dynamicTree value to set.
     * @return the SwaggerSchema object itself.
     */
    public SwaggerSchema withDynamicTree(SwaggerCustomDynamicTree dynamicTree) {
        this.dynamicTree = dynamicTree;
        return this;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (items() != null) {
            items().validate();
        }
        if (properties() != null) {
            properties()
                .values()
                .forEach(
                    e -> {
                        if (e != null) {
                            e.validate();
                        }
                    });
        }
        if (allOf() != null) {
            allOf().forEach(e -> e.validate());
        }
        if (xml() != null) {
            xml().validate();
        }
        if (externalDocs() != null) {
            externalDocs().validate();
        }
        if (dynamicSchemaOld() != null) {
            dynamicSchemaOld().validate();
        }
        if (dynamicSchemaNew() != null) {
            dynamicSchemaNew().validate();
        }
        if (dynamicListNew() != null) {
            dynamicListNew().validate();
        }
        if (dynamicTree() != null) {
            dynamicTree().validate();
        }
    }
}
