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.collect.ImmutableList;
11 import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections;
12 import org.opendaylight.protocol.bgp.rib.spi.RIBQNames;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.Tables;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey;
15 import org.opendaylight.yangtools.util.ImmutableOffsetMapTemplate;
16 import org.opendaylight.yangtools.yang.common.QName;
17 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
19 final class RibSupportUtils {
20 private static final ImmutableOffsetMapTemplate<QName> AFI_SAFI_TEMPLATE =
21 ImmutableOffsetMapTemplate.ordered(ImmutableList.of(RIBQNames.AFI_QNAME, RIBQNames.SAFI_QNAME));
23 private RibSupportUtils() {
28 * Creates Yang Instance Identifier path argument from supplied {@link TablesKey}.
30 * @param tablesKey Tables key representing table.
31 * @return NodeIdentifierWithPredicates of {@link Tables} for specified AFI, SAFI combination.
33 static NodeIdentifierWithPredicates toYangTablesKey(final TablesKey tablesKey) {
34 return NodeIdentifierWithPredicates.of(Tables.QNAME, AFI_SAFI_TEMPLATE.instantiateWithValues(
35 BindingReflections.getQName(tablesKey.getAfi()), BindingReflections.getQName(tablesKey.getSafi())));