1 package org.opendaylight.openflowplugin.learningswitch;
3 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
4 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
5 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey;
6 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
7 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey;
8 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector;
9 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey;
10 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
11 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
14 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
17 public class InstanceIdentifierUtils {
19 private InstanceIdentifierUtils() {
20 //hiding constructor for util class
24 * Creates an Instance Identifier (path) for node with specified id
29 public static final InstanceIdentifier<Node> createNodePath(NodeId nodeId) {
30 return InstanceIdentifier.builder(Nodes.class)
31 .child(Node.class, new NodeKey(nodeId))
36 * Shorten's node child path to node path.
38 * @param nodeChild child of node, from which we want node path.
41 public static final InstanceIdentifier<Node> getNodePath(InstanceIdentifier<?> nodeChild) {
42 return nodeChild.firstIdentifierOf(Node.class);
47 * Creates a table path by appending table specific location to node path
53 public static final InstanceIdentifier<Table> createTablePath(InstanceIdentifier<Node> nodePath,TableKey tableKey) {
54 return InstanceIdentifier.builder(nodePath)
55 .augmentation(FlowCapableNode.class)
56 .child(Table.class, tableKey)
61 * Creates a path for particular flow, by appending flow-specific information
66 * @return path to flow
68 public static InstanceIdentifier<Flow> createFlowPath(InstanceIdentifier<Table> tablePath, FlowKey flowKey) {
69 return InstanceIdentifier.builder(tablePath)
70 .child(Flow.class, flowKey)
75 * Extract table id from table path.
80 public static Short getTableId(InstanceIdentifier<Table> tablePath) {
81 return tablePath.firstKeyOf(Table.class, TableKey.class).getId();
85 * Extracts NodeConnectorKey from node connector path.
88 public static NodeConnectorKey getNodeConnectorKey(InstanceIdentifier<?> nodeConnectorPath) {
89 return nodeConnectorPath.firstKeyOf(NodeConnector.class, NodeConnectorKey.class);
94 public static final InstanceIdentifier<NodeConnector> createNodeConnectorPath(InstanceIdentifier<Node> nodeKey,NodeConnectorKey nodeConnectorKey) {
95 return InstanceIdentifier.builder(nodeKey)
96 .child(NodeConnector.class,nodeConnectorKey)