2 * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.protocol.bgp.rib.impl;
10 import com.google.common.base.Preconditions;
11 import java.util.Collection;
13 import org.opendaylight.protocol.bgp.rib.spi.PeerExportGroup;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.PeerId;
15 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
17 final class PeerExportGroupImpl implements PeerExportGroup {
18 private final Map<PeerId, PeerExporTuple> peers;
19 private final AbstractExportPolicy policy;
21 public PeerExportGroupImpl(final Map<PeerId, PeerExporTuple> peers, final AbstractExportPolicy policy) {
22 this.peers = Preconditions.checkNotNull(peers);
23 this.policy = Preconditions.checkNotNull(policy);
27 public ContainerNode effectiveAttributes(final PeerId sourcePeerId, final ContainerNode attributes) {
28 final PeerExporTuple peer = this.peers.get(sourcePeerId);
29 return attributes == null || peer == null ? null : policy.effectiveAttributes(peer.getRole(), attributes);
33 public Collection<Map.Entry<PeerId, PeerExporTuple>> getPeers() {
34 return peers.entrySet();