// 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;

/** Maps fields in Profile to their corresponding StrongIds in Related Profile. */
@Fluent
public final class RelationshipTypeMapping {
    /*
     * Maps a profile property with the StrongId of related profile. This is an array to support StrongIds that are
     * composite key as well.
     */
    @JsonProperty(value = "fieldMappings", required = true)
    private List<RelationshipTypeFieldMapping> fieldMappings;

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

    /**
     * Get the fieldMappings property: Maps a profile property with the StrongId of related profile. This is an array to
     * support StrongIds that are composite key as well.
     *
     * @return the fieldMappings value.
     */
    public List<RelationshipTypeFieldMapping> fieldMappings() {
        return this.fieldMappings;
    }

    /**
     * Set the fieldMappings property: Maps a profile property with the StrongId of related profile. This is an array to
     * support StrongIds that are composite key as well.
     *
     * @param fieldMappings the fieldMappings value to set.
     * @return the RelationshipTypeMapping object itself.
     */
    public RelationshipTypeMapping withFieldMappings(List<RelationshipTypeFieldMapping> fieldMappings) {
        this.fieldMappings = fieldMappings;
        return this;
    }

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

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