MVPN RFC6514 Extendend communities
[bgpcep.git] / bgp / parser-spi / src / main / java / org / opendaylight / protocol / bgp / parser / spi / MultiPathSupportUtil.java
1 /*
2  * Copyright (c) 2016 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
9 package org.opendaylight.protocol.bgp.parser.spi;
10
11 import static java.util.Objects.requireNonNull;
12
13 import java.util.Optional;
14 import javax.annotation.Nonnull;
15 import javax.annotation.Nullable;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.BgpTableType;
17
18 public final class MultiPathSupportUtil {
19
20     private MultiPathSupportUtil() {
21         throw new UnsupportedOperationException();
22     }
23
24     /**
25      * Check is AFI/SAFI is supported by {@link MultiPathSupport} service.
26      * @param constraints Peer specific constraint.
27      * @param afiSafi Required AFI/SAFI
28      * @return True if AFI/SAFI is supported.
29      */
30     public static boolean isTableTypeSupported(@Nullable final PeerSpecificParserConstraint constraints, @Nonnull final BgpTableType afiSafi) {
31         requireNonNull(afiSafi);
32         if (constraints != null) {
33             final Optional<MultiPathSupport> peerConstraint = constraints.getPeerConstraint(MultiPathSupport.class);
34             return peerConstraint.isPresent() && peerConstraint.get().isTableTypeSupported(afiSafi);
35         }
36         return false;
37
38     }
39
40 }