Remove unnecesary imports
[bgpcep.git] / bgp / rib-impl / src / main / java / org / opendaylight / protocol / bgp / rib / impl / ToExternalExportPolicy.java
1 /*
2  * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.protocol.bgp.rib.impl;
9
10 import static java.util.Objects.requireNonNull;
11
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.PeerRole;
13 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
14
15 /**
16  * Invoked on routes which we send outside of our home AS.
17  */
18 final class ToExternalExportPolicy extends AbstractExportPolicy {
19     private final Long localAs;
20
21     ToExternalExportPolicy(final Long localAs) {
22         this.localAs = requireNonNull(localAs);
23     }
24
25     @Override
26     ContainerNode effectiveAttributes(final PeerRole sourceRole, final ContainerNode attributes) {
27         final ContainerNode ret = AttributeOperations.getInstance(attributes).exportedAttributes(attributes, this.localAs);
28
29         switch (sourceRole) {
30         case Ebgp:
31             // eBGP -> eBGP, propagate
32             return ret;
33         case Ibgp:
34             // Non-Client iBGP -> eBGP, propagate
35             return ret;
36         case RrClient:
37             // Client iBGP -> eBGP, propagate
38             return ret;
39         case Internal:
40             // Internal iBGP -> eBGP, propagate
41             return ret;
42         default:
43             throw new IllegalArgumentException("Unhandled source role " + sourceRole);
44         }
45     }
46 }