Use ByteBuf.readRetainedSlice()
[openflowplugin.git] / openflowplugin-impl / src / main / java / org / opendaylight / openflowplugin / impl / util / PathUtil.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 package org.opendaylight.openflowplugin.impl.util;
9
10 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
11 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
13 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
14
15 /**
16  * Purpose: utility class providing path and {@link InstanceIdentifier} tools.
17  */
18 public final class PathUtil {
19     private PathUtil() {
20         // Hidden on purpose
21     }
22
23     /**
24      * Extracts node id from instance identifier.
25      * @param input instance identifier
26      * @return node-id from given instance identifier
27      */
28     public static NodeId extractNodeId(final InstanceIdentifier<Node> input) {
29         return input.firstKeyOf(Node.class).getId();
30     }
31
32     /**
33      * Extracts node id from node reference.
34      * @param input reference to {@link Node}
35      * @return node-id from given reference
36      */
37     public static NodeId extractNodeId(final NodeRef input) {
38         return input.getValue().firstKeyOf(Node.class).getId();
39     }
40 }