BUG-6647 Increase code coverage and clean up I
[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 com.google.common.base.Preconditions;
12 import java.util.Optional;
13 import javax.annotation.Nonnull;
14 import javax.annotation.Nullable;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.BgpTableType;
16
17 public final class MultiPathSupportUtil {
18
19     private MultiPathSupportUtil() {
20         throw new UnsupportedOperationException();
21     }
22
23     /**
24      * Check is AFI/SAFI is supported by {@link MultiPathSupport} service.
25      * @param constraints Peer specific constraint.
26      * @param afiSafi Required AFI/SAFI
27      * @return True if AFI/SAFI is supported.
28      */
29     public static boolean isTableTypeSupported(@Nullable final PeerSpecificParserConstraint constraints, @Nonnull final BgpTableType afiSafi) {
30         Preconditions.checkNotNull(afiSafi);
31         if (constraints != null) {
32             final Optional<MultiPathSupport> peerConstraint = constraints.getPeerConstraint(MultiPathSupport.class);
33             return peerConstraint.isPresent() && peerConstraint.get().isTableTypeSupported(afiSafi);
34         }
35         return false;
36
37     }
38
39 }