// 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.fluent.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
import com.azure.resourcemanager.customerinsights.models.CardinalityTypes;
import com.azure.resourcemanager.customerinsights.models.PropertyDefinition;
import com.azure.resourcemanager.customerinsights.models.ProvisioningStates;
import com.azure.resourcemanager.customerinsights.models.RelationshipTypeMapping;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.time.OffsetDateTime;
import java.util.List;
import java.util.Map;

/** The definition of Relationship. */
@Fluent
public final class RelationshipDefinition {
    /*
     * The Relationship Cardinality.
     */
    @JsonProperty(value = "cardinality")
    private CardinalityTypes cardinality;

    /*
     * Localized display name for the Relationship.
     */
    @JsonProperty(value = "displayName")
    @JsonInclude(value = JsonInclude.Include.NON_NULL, content = JsonInclude.Include.ALWAYS)
    private Map<String, String> displayName;

    /*
     * Localized descriptions for the Relationship.
     */
    @JsonProperty(value = "description")
    @JsonInclude(value = JsonInclude.Include.NON_NULL, content = JsonInclude.Include.ALWAYS)
    private Map<String, String> description;

    /*
     * The expiry date time in UTC.
     */
    @JsonProperty(value = "expiryDateTimeUtc")
    private OffsetDateTime expiryDateTimeUtc;

    /*
     * The properties of the Relationship.
     */
    @JsonProperty(value = "fields")
    private List<PropertyDefinition> fields;

    /*
     * Optional property to be used to map fields in profile to their strong ids in related profile.
     */
    @JsonProperty(value = "lookupMappings")
    private List<RelationshipTypeMapping> lookupMappings;

    /*
     * Profile type.
     */
    @JsonProperty(value = "profileType", required = true)
    private String profileType;

    /*
     * Provisioning state.
     */
    @JsonProperty(value = "provisioningState", access = JsonProperty.Access.WRITE_ONLY)
    private ProvisioningStates provisioningState;

    /*
     * The Relationship name.
     */
    @JsonProperty(value = "relationshipName", access = JsonProperty.Access.WRITE_ONLY)
    private String relationshipName;

    /*
     * Related profile being referenced.
     */
    @JsonProperty(value = "relatedProfileType", required = true)
    private String relatedProfileType;

    /*
     * The relationship guid id.
     */
    @JsonProperty(value = "relationshipGuidId", access = JsonProperty.Access.WRITE_ONLY)
    private String relationshipGuidId;

    /*
     * The hub name.
     */
    @JsonProperty(value = "tenantId", access = JsonProperty.Access.WRITE_ONLY)
    private String tenantId;

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

    /**
     * Get the cardinality property: The Relationship Cardinality.
     *
     * @return the cardinality value.
     */
    public CardinalityTypes cardinality() {
        return this.cardinality;
    }

    /**
     * Set the cardinality property: The Relationship Cardinality.
     *
     * @param cardinality the cardinality value to set.
     * @return the RelationshipDefinition object itself.
     */
    public RelationshipDefinition withCardinality(CardinalityTypes cardinality) {
        this.cardinality = cardinality;
        return this;
    }

    /**
     * Get the displayName property: Localized display name for the Relationship.
     *
     * @return the displayName value.
     */
    public Map<String, String> displayName() {
        return this.displayName;
    }

    /**
     * Set the displayName property: Localized display name for the Relationship.
     *
     * @param displayName the displayName value to set.
     * @return the RelationshipDefinition object itself.
     */
    public RelationshipDefinition withDisplayName(Map<String, String> displayName) {
        this.displayName = displayName;
        return this;
    }

    /**
     * Get the description property: Localized descriptions for the Relationship.
     *
     * @return the description value.
     */
    public Map<String, String> description() {
        return this.description;
    }

    /**
     * Set the description property: Localized descriptions for the Relationship.
     *
     * @param description the description value to set.
     * @return the RelationshipDefinition object itself.
     */
    public RelationshipDefinition withDescription(Map<String, String> description) {
        this.description = description;
        return this;
    }

    /**
     * Get the expiryDateTimeUtc property: The expiry date time in UTC.
     *
     * @return the expiryDateTimeUtc value.
     */
    public OffsetDateTime expiryDateTimeUtc() {
        return this.expiryDateTimeUtc;
    }

    /**
     * Set the expiryDateTimeUtc property: The expiry date time in UTC.
     *
     * @param expiryDateTimeUtc the expiryDateTimeUtc value to set.
     * @return the RelationshipDefinition object itself.
     */
    public RelationshipDefinition withExpiryDateTimeUtc(OffsetDateTime expiryDateTimeUtc) {
        this.expiryDateTimeUtc = expiryDateTimeUtc;
        return this;
    }

    /**
     * Get the fields property: The properties of the Relationship.
     *
     * @return the fields value.
     */
    public List<PropertyDefinition> fields() {
        return this.fields;
    }

    /**
     * Set the fields property: The properties of the Relationship.
     *
     * @param fields the fields value to set.
     * @return the RelationshipDefinition object itself.
     */
    public RelationshipDefinition withFields(List<PropertyDefinition> fields) {
        this.fields = fields;
        return this;
    }

    /**
     * Get the lookupMappings property: Optional property to be used to map fields in profile to their strong ids in
     * related profile.
     *
     * @return the lookupMappings value.
     */
    public List<RelationshipTypeMapping> lookupMappings() {
        return this.lookupMappings;
    }

    /**
     * Set the lookupMappings property: Optional property to be used to map fields in profile to their strong ids in
     * related profile.
     *
     * @param lookupMappings the lookupMappings value to set.
     * @return the RelationshipDefinition object itself.
     */
    public RelationshipDefinition withLookupMappings(List<RelationshipTypeMapping> lookupMappings) {
        this.lookupMappings = lookupMappings;
        return this;
    }

    /**
     * Get the profileType property: Profile type.
     *
     * @return the profileType value.
     */
    public String profileType() {
        return this.profileType;
    }

    /**
     * Set the profileType property: Profile type.
     *
     * @param profileType the profileType value to set.
     * @return the RelationshipDefinition object itself.
     */
    public RelationshipDefinition withProfileType(String profileType) {
        this.profileType = profileType;
        return this;
    }

    /**
     * Get the provisioningState property: Provisioning state.
     *
     * @return the provisioningState value.
     */
    public ProvisioningStates provisioningState() {
        return this.provisioningState;
    }

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

    /**
     * Get the relatedProfileType property: Related profile being referenced.
     *
     * @return the relatedProfileType value.
     */
    public String relatedProfileType() {
        return this.relatedProfileType;
    }

    /**
     * Set the relatedProfileType property: Related profile being referenced.
     *
     * @param relatedProfileType the relatedProfileType value to set.
     * @return the RelationshipDefinition object itself.
     */
    public RelationshipDefinition withRelatedProfileType(String relatedProfileType) {
        this.relatedProfileType = relatedProfileType;
        return this;
    }

    /**
     * Get the relationshipGuidId property: The relationship guid id.
     *
     * @return the relationshipGuidId value.
     */
    public String relationshipGuidId() {
        return this.relationshipGuidId;
    }

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

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (fields() != null) {
            fields().forEach(e -> e.validate());
        }
        if (lookupMappings() != null) {
            lookupMappings().forEach(e -> e.validate());
        }
        if (profileType() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property profileType in model RelationshipDefinition"));
        }
        if (relatedProfileType() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property relatedProfileType in model RelationshipDefinition"));
        }
    }

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