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.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.PeerRole;
16 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
18 final class PeerExportGroupImpl implements PeerExportGroup {
19 private final Map<PeerId, PeerExporTuple> peers;
20 private final AbstractExportPolicy policy;
22 public PeerExportGroupImpl(final Map<PeerId, PeerExporTuple> peers, final AbstractExportPolicy policy) {
23 this.peers = Preconditions.checkNotNull(peers);
24 this.policy = Preconditions.checkNotNull(policy);
28 public ContainerNode effectiveAttributes(final PeerRole role, final ContainerNode attributes) {
29 return attributes == null || role == null ? null : policy.effectiveAttributes(role, attributes);
33 public Collection<Map.Entry<PeerId, PeerExporTuple>> getPeers() {
34 return peers.entrySet();
38 public boolean containsPeer(final PeerId routePeerId) {
39 return this.peers.containsKey(routePeerId);