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

package com.azure.resourcemanager.customerinsights.models;

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

/** Property definition. */
@Fluent
public final class PropertyDefinition {
    /*
     * Array value separator for properties with isArray set.
     */
    @JsonProperty(value = "arrayValueSeparator")
    private String arrayValueSeparator;

    /*
     * Describes valid values for an enum property.
     */
    @JsonProperty(value = "enumValidValues")
    private List<ProfileEnumValidValuesFormat> enumValidValues;

    /*
     * Name of the property.
     */
    @JsonProperty(value = "fieldName", required = true)
    private String fieldName;

    /*
     * Type of the property.
     */
    @JsonProperty(value = "fieldType", required = true)
    private String fieldType;

    /*
     * Indicates if the property is actually an array of the fieldType above on the data api.
     */
    @JsonProperty(value = "isArray")
    private Boolean isArray;

    /*
     * Indicates if the property is an enum.
     */
    @JsonProperty(value = "isEnum")
    private Boolean isEnum;

    /*
     * Indicates if the property is an flag enum.
     */
    @JsonProperty(value = "isFlagEnum")
    private Boolean isFlagEnum;

    /*
     * Whether the property is an Image.
     */
    @JsonProperty(value = "isImage")
    private Boolean isImage;

    /*
     * Whether the property is a localized string.
     */
    @JsonProperty(value = "isLocalizedString")
    private Boolean isLocalizedString;

    /*
     * Whether the property is a name or a part of name.
     */
    @JsonProperty(value = "isName")
    private Boolean isName;

    /*
     * Whether property value is required on instances, IsRequired field only for Interaction. Profile Instance will
     * not check for required field.
     */
    @JsonProperty(value = "isRequired")
    private Boolean isRequired;

    /*
     * The ID associated with the property.
     */
    @JsonProperty(value = "propertyId")
    private String propertyId;

    /*
     * URL encoded schema.org item prop link for the property.
     */
    @JsonProperty(value = "schemaItemPropLink")
    private String schemaItemPropLink;

    /*
     * Max length of string. Used only if type is string.
     */
    @JsonProperty(value = "maxLength")
    private Integer maxLength;

    /*
     * Whether property is available in graph or not.
     */
    @JsonProperty(value = "isAvailableInGraph")
    private Boolean isAvailableInGraph;

    /*
     * This is specific to interactions modeled as activities. Data sources are used to determine where data is stored
     * and also in precedence rules.
     */
    @JsonProperty(value = "dataSourcePrecedenceRules", access = JsonProperty.Access.WRITE_ONLY)
    private List<DataSourcePrecedence> dataSourcePrecedenceRules;

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

    /**
     * Get the arrayValueSeparator property: Array value separator for properties with isArray set.
     *
     * @return the arrayValueSeparator value.
     */
    public String arrayValueSeparator() {
        return this.arrayValueSeparator;
    }

    /**
     * Set the arrayValueSeparator property: Array value separator for properties with isArray set.
     *
     * @param arrayValueSeparator the arrayValueSeparator value to set.
     * @return the PropertyDefinition object itself.
     */
    public PropertyDefinition withArrayValueSeparator(String arrayValueSeparator) {
        this.arrayValueSeparator = arrayValueSeparator;
        return this;
    }

    /**
     * Get the enumValidValues property: Describes valid values for an enum property.
     *
     * @return the enumValidValues value.
     */
    public List<ProfileEnumValidValuesFormat> enumValidValues() {
        return this.enumValidValues;
    }

    /**
     * Set the enumValidValues property: Describes valid values for an enum property.
     *
     * @param enumValidValues the enumValidValues value to set.
     * @return the PropertyDefinition object itself.
     */
    public PropertyDefinition withEnumValidValues(List<ProfileEnumValidValuesFormat> enumValidValues) {
        this.enumValidValues = enumValidValues;
        return this;
    }

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

    /**
     * Set the fieldName property: Name of the property.
     *
     * @param fieldName the fieldName value to set.
     * @return the PropertyDefinition object itself.
     */
    public PropertyDefinition withFieldName(String fieldName) {
        this.fieldName = fieldName;
        return this;
    }

    /**
     * Get the fieldType property: Type of the property.
     *
     * @return the fieldType value.
     */
    public String fieldType() {
        return this.fieldType;
    }

    /**
     * Set the fieldType property: Type of the property.
     *
     * @param fieldType the fieldType value to set.
     * @return the PropertyDefinition object itself.
     */
    public PropertyDefinition withFieldType(String fieldType) {
        this.fieldType = fieldType;
        return this;
    }

    /**
     * Get the isArray property: Indicates if the property is actually an array of the fieldType above on the data api.
     *
     * @return the isArray value.
     */
    public Boolean isArray() {
        return this.isArray;
    }

    /**
     * Set the isArray property: Indicates if the property is actually an array of the fieldType above on the data api.
     *
     * @param isArray the isArray value to set.
     * @return the PropertyDefinition object itself.
     */
    public PropertyDefinition withIsArray(Boolean isArray) {
        this.isArray = isArray;
        return this;
    }

    /**
     * Get the isEnum property: Indicates if the property is an enum.
     *
     * @return the isEnum value.
     */
    public Boolean isEnum() {
        return this.isEnum;
    }

    /**
     * Set the isEnum property: Indicates if the property is an enum.
     *
     * @param isEnum the isEnum value to set.
     * @return the PropertyDefinition object itself.
     */
    public PropertyDefinition withIsEnum(Boolean isEnum) {
        this.isEnum = isEnum;
        return this;
    }

    /**
     * Get the isFlagEnum property: Indicates if the property is an flag enum.
     *
     * @return the isFlagEnum value.
     */
    public Boolean isFlagEnum() {
        return this.isFlagEnum;
    }

    /**
     * Set the isFlagEnum property: Indicates if the property is an flag enum.
     *
     * @param isFlagEnum the isFlagEnum value to set.
     * @return the PropertyDefinition object itself.
     */
    public PropertyDefinition withIsFlagEnum(Boolean isFlagEnum) {
        this.isFlagEnum = isFlagEnum;
        return this;
    }

    /**
     * Get the isImage property: Whether the property is an Image.
     *
     * @return the isImage value.
     */
    public Boolean isImage() {
        return this.isImage;
    }

    /**
     * Set the isImage property: Whether the property is an Image.
     *
     * @param isImage the isImage value to set.
     * @return the PropertyDefinition object itself.
     */
    public PropertyDefinition withIsImage(Boolean isImage) {
        this.isImage = isImage;
        return this;
    }

    /**
     * Get the isLocalizedString property: Whether the property is a localized string.
     *
     * @return the isLocalizedString value.
     */
    public Boolean isLocalizedString() {
        return this.isLocalizedString;
    }

    /**
     * Set the isLocalizedString property: Whether the property is a localized string.
     *
     * @param isLocalizedString the isLocalizedString value to set.
     * @return the PropertyDefinition object itself.
     */
    public PropertyDefinition withIsLocalizedString(Boolean isLocalizedString) {
        this.isLocalizedString = isLocalizedString;
        return this;
    }

    /**
     * Get the isName property: Whether the property is a name or a part of name.
     *
     * @return the isName value.
     */
    public Boolean isName() {
        return this.isName;
    }

    /**
     * Set the isName property: Whether the property is a name or a part of name.
     *
     * @param isName the isName value to set.
     * @return the PropertyDefinition object itself.
     */
    public PropertyDefinition withIsName(Boolean isName) {
        this.isName = isName;
        return this;
    }

    /**
     * Get the isRequired property: Whether property value is required on instances, IsRequired field only for
     * Interaction. Profile Instance will not check for required field.
     *
     * @return the isRequired value.
     */
    public Boolean isRequired() {
        return this.isRequired;
    }

    /**
     * Set the isRequired property: Whether property value is required on instances, IsRequired field only for
     * Interaction. Profile Instance will not check for required field.
     *
     * @param isRequired the isRequired value to set.
     * @return the PropertyDefinition object itself.
     */
    public PropertyDefinition withIsRequired(Boolean isRequired) {
        this.isRequired = isRequired;
        return this;
    }

    /**
     * Get the propertyId property: The ID associated with the property.
     *
     * @return the propertyId value.
     */
    public String propertyId() {
        return this.propertyId;
    }

    /**
     * Set the propertyId property: The ID associated with the property.
     *
     * @param propertyId the propertyId value to set.
     * @return the PropertyDefinition object itself.
     */
    public PropertyDefinition withPropertyId(String propertyId) {
        this.propertyId = propertyId;
        return this;
    }

    /**
     * Get the schemaItemPropLink property: URL encoded schema.org item prop link for the property.
     *
     * @return the schemaItemPropLink value.
     */
    public String schemaItemPropLink() {
        return this.schemaItemPropLink;
    }

    /**
     * Set the schemaItemPropLink property: URL encoded schema.org item prop link for the property.
     *
     * @param schemaItemPropLink the schemaItemPropLink value to set.
     * @return the PropertyDefinition object itself.
     */
    public PropertyDefinition withSchemaItemPropLink(String schemaItemPropLink) {
        this.schemaItemPropLink = schemaItemPropLink;
        return this;
    }

    /**
     * Get the maxLength property: Max length of string. Used only if type is string.
     *
     * @return the maxLength value.
     */
    public Integer maxLength() {
        return this.maxLength;
    }

    /**
     * Set the maxLength property: Max length of string. Used only if type is string.
     *
     * @param maxLength the maxLength value to set.
     * @return the PropertyDefinition object itself.
     */
    public PropertyDefinition withMaxLength(Integer maxLength) {
        this.maxLength = maxLength;
        return this;
    }

    /**
     * Get the isAvailableInGraph property: Whether property is available in graph or not.
     *
     * @return the isAvailableInGraph value.
     */
    public Boolean isAvailableInGraph() {
        return this.isAvailableInGraph;
    }

    /**
     * Set the isAvailableInGraph property: Whether property is available in graph or not.
     *
     * @param isAvailableInGraph the isAvailableInGraph value to set.
     * @return the PropertyDefinition object itself.
     */
    public PropertyDefinition withIsAvailableInGraph(Boolean isAvailableInGraph) {
        this.isAvailableInGraph = isAvailableInGraph;
        return this;
    }

    /**
     * Get the dataSourcePrecedenceRules property: This is specific to interactions modeled as activities. Data sources
     * are used to determine where data is stored and also in precedence rules.
     *
     * @return the dataSourcePrecedenceRules value.
     */
    public List<DataSourcePrecedence> dataSourcePrecedenceRules() {
        return this.dataSourcePrecedenceRules;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (enumValidValues() != null) {
            enumValidValues().forEach(e -> e.validate());
        }
        if (fieldName() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException("Missing required property fieldName in model PropertyDefinition"));
        }
        if (fieldType() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException("Missing required property fieldType in model PropertyDefinition"));
        }
        if (dataSourcePrecedenceRules() != null) {
            dataSourcePrecedenceRules().forEach(e -> e.validate());
        }
    }

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