// 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.ParticipantProfilePropertyReference;
import com.azure.resourcemanager.customerinsights.models.ProvisioningStates;
import com.azure.resourcemanager.customerinsights.models.RelationshipLinkFieldMapping;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
import java.util.Map;

/** The definition of relationship link. */
@Fluent
public final class RelationshipLinkDefinition {
    /*
     * Localized display name for the Relationship Link.
     */
    @JsonProperty(value = "displayName")
    @JsonInclude(value = JsonInclude.Include.NON_NULL, content = JsonInclude.Include.ALWAYS)
    private Map<String, String> displayName;

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

    /*
     * The InteractionType associated with the Relationship Link.
     */
    @JsonProperty(value = "interactionType", required = true)
    private String interactionType;

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

    /*
     * The mappings between Interaction and Relationship fields.
     */
    @JsonProperty(value = "mappings")
    private List<RelationshipLinkFieldMapping> mappings;

    /*
     * The property references for the Profile of the Relationship.
     */
    @JsonProperty(value = "profilePropertyReferences", required = true)
    private List<ParticipantProfilePropertyReference> profilePropertyReferences;

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

    /*
     * The property references for the Related Profile of the Relationship.
     */
    @JsonProperty(value = "relatedProfilePropertyReferences", required = true)
    private List<ParticipantProfilePropertyReference> relatedProfilePropertyReferences;

    /*
     * The Relationship associated with the Link.
     */
    @JsonProperty(value = "relationshipName", required = true)
    private String relationshipName;

    /*
     * 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 RelationshipLinkDefinition class. */
    public RelationshipLinkDefinition() {
    }

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

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

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

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

    /**
     * Get the interactionType property: The InteractionType associated with the Relationship Link.
     *
     * @return the interactionType value.
     */
    public String interactionType() {
        return this.interactionType;
    }

    /**
     * Set the interactionType property: The InteractionType associated with the Relationship Link.
     *
     * @param interactionType the interactionType value to set.
     * @return the RelationshipLinkDefinition object itself.
     */
    public RelationshipLinkDefinition withInteractionType(String interactionType) {
        this.interactionType = interactionType;
        return this;
    }

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

    /**
     * Get the mappings property: The mappings between Interaction and Relationship fields.
     *
     * @return the mappings value.
     */
    public List<RelationshipLinkFieldMapping> mappings() {
        return this.mappings;
    }

    /**
     * Set the mappings property: The mappings between Interaction and Relationship fields.
     *
     * @param mappings the mappings value to set.
     * @return the RelationshipLinkDefinition object itself.
     */
    public RelationshipLinkDefinition withMappings(List<RelationshipLinkFieldMapping> mappings) {
        this.mappings = mappings;
        return this;
    }

    /**
     * Get the profilePropertyReferences property: The property references for the Profile of the Relationship.
     *
     * @return the profilePropertyReferences value.
     */
    public List<ParticipantProfilePropertyReference> profilePropertyReferences() {
        return this.profilePropertyReferences;
    }

    /**
     * Set the profilePropertyReferences property: The property references for the Profile of the Relationship.
     *
     * @param profilePropertyReferences the profilePropertyReferences value to set.
     * @return the RelationshipLinkDefinition object itself.
     */
    public RelationshipLinkDefinition withProfilePropertyReferences(
        List<ParticipantProfilePropertyReference> profilePropertyReferences) {
        this.profilePropertyReferences = profilePropertyReferences;
        return this;
    }

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

    /**
     * Get the relatedProfilePropertyReferences property: The property references for the Related Profile of the
     * Relationship.
     *
     * @return the relatedProfilePropertyReferences value.
     */
    public List<ParticipantProfilePropertyReference> relatedProfilePropertyReferences() {
        return this.relatedProfilePropertyReferences;
    }

    /**
     * Set the relatedProfilePropertyReferences property: The property references for the Related Profile of the
     * Relationship.
     *
     * @param relatedProfilePropertyReferences the relatedProfilePropertyReferences value to set.
     * @return the RelationshipLinkDefinition object itself.
     */
    public RelationshipLinkDefinition withRelatedProfilePropertyReferences(
        List<ParticipantProfilePropertyReference> relatedProfilePropertyReferences) {
        this.relatedProfilePropertyReferences = relatedProfilePropertyReferences;
        return this;
    }

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

    /**
     * Set the relationshipName property: The Relationship associated with the Link.
     *
     * @param relationshipName the relationshipName value to set.
     * @return the RelationshipLinkDefinition object itself.
     */
    public RelationshipLinkDefinition withRelationshipName(String relationshipName) {
        this.relationshipName = relationshipName;
        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 (interactionType() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property interactionType in model RelationshipLinkDefinition"));
        }
        if (mappings() != null) {
            mappings().forEach(e -> e.validate());
        }
        if (profilePropertyReferences() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property profilePropertyReferences in model RelationshipLinkDefinition"));
        } else {
            profilePropertyReferences().forEach(e -> e.validate());
        }
        if (relatedProfilePropertyReferences() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property relatedProfilePropertyReferences in model"
                            + " RelationshipLinkDefinition"));
        } else {
            relatedProfilePropertyReferences().forEach(e -> e.validate());
        }
        if (relationshipName() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property relationshipName in model RelationshipLinkDefinition"));
        }
    }

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