BGPCEP-754: Start using default import policy
[bgpcep.git] / bgp / rib-impl / src / main / java / org / opendaylight / protocol / bgp / rib / impl / config / RoutingPolicyUtil.java
1 /*
2  * Copyright (c) 2018 AT&T Intellectual Property. 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.config;
9
10 import static org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.DefaultPolicyType.ACCEPTROUTE;
11
12 import java.util.Collections;
13 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.apply.policy.group.ApplyPolicy;
14 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.apply.policy.group.apply.policy.Config;
15 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.apply.policy.group.apply.policy.ConfigBuilder;
16
17 public final class RoutingPolicyUtil {
18
19     private static final Config DEFAULT_POLICY = new ConfigBuilder().setDefaultImportPolicy(ACCEPTROUTE)
20             .setDefaultExportPolicy(ACCEPTROUTE).setImportPolicy(Collections.emptyList())
21             .setExportPolicy(Collections.emptyList()).build();
22
23     private RoutingPolicyUtil() {
24         throw new UnsupportedOperationException();
25     }
26
27     public static Config getApplyPolicy(final ApplyPolicy applyPolicy) {
28         if (applyPolicy == null) {
29             return DEFAULT_POLICY;
30         }
31         return applyPolicy.getConfig();
32     }
33 }