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

package com.azure.resourcemanager.peering.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.management.SubResource;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;

/** The properties that define an exchange peering. */
@Fluent
public final class PeeringPropertiesExchange {
    /*
     * The set of connections that constitute an exchange peering.
     */
    @JsonProperty(value = "connections")
    private List<ExchangeConnection> connections;

    /*
     * The reference of the peer ASN.
     */
    @JsonProperty(value = "peerAsn")
    private SubResource peerAsn;

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

    /**
     * Get the connections property: The set of connections that constitute an exchange peering.
     *
     * @return the connections value.
     */
    public List<ExchangeConnection> connections() {
        return this.connections;
    }

    /**
     * Set the connections property: The set of connections that constitute an exchange peering.
     *
     * @param connections the connections value to set.
     * @return the PeeringPropertiesExchange object itself.
     */
    public PeeringPropertiesExchange withConnections(List<ExchangeConnection> connections) {
        this.connections = connections;
        return this;
    }

    /**
     * Get the peerAsn property: The reference of the peer ASN.
     *
     * @return the peerAsn value.
     */
    public SubResource peerAsn() {
        return this.peerAsn;
    }

    /**
     * Set the peerAsn property: The reference of the peer ASN.
     *
     * @param peerAsn the peerAsn value to set.
     * @return the PeeringPropertiesExchange object itself.
     */
    public PeeringPropertiesExchange withPeerAsn(SubResource peerAsn) {
        this.peerAsn = peerAsn;
        return this;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (connections() != null) {
            connections().forEach(e -> e.validate());
        }
    }
}
