1 package org.opendaylight.controller.cluster.datastore.utils;
3 import org.opendaylight.controller.cluster.datastore.node.utils.NodeIdentifierFactory;
4 import org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages;
5 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
6 import org.slf4j.Logger;
7 import org.slf4j.LoggerFactory;
9 import java.util.ArrayList;
10 import java.util.List;
15 public class InstanceIdentifierUtils {
17 protected static final Logger logger = LoggerFactory
18 .getLogger(InstanceIdentifierUtils.class);
20 public static String getParentPath(String currentElementPath) {
21 String parentPath = "";
23 if (currentElementPath != null) {
24 String[] parentPaths = currentElementPath.split("/");
25 if (parentPaths.length > 2) {
26 for (int i = 0; i < parentPaths.length - 1; i++) {
27 if (parentPaths[i].length() > 0) {
28 parentPath += "/" + parentPaths[i];
37 public static YangInstanceIdentifier from(String path) {
38 String[] ids = path.split("/");
40 List<YangInstanceIdentifier.PathArgument> pathArguments =
42 for (String nodeId : ids) {
43 if (!"".equals(nodeId)) {
45 .add(NodeIdentifierFactory.getArgument(nodeId));
48 final YangInstanceIdentifier instanceIdentifier =
49 YangInstanceIdentifier.create(pathArguments);
50 return instanceIdentifier;
54 * @deprecated Use {@link org.opendaylight.controller.cluster.datastore.util.InstanceIdentifierUtils} instead
59 public static NormalizedNodeMessages.InstanceIdentifier toSerializable(YangInstanceIdentifier path){
60 return org.opendaylight.controller.cluster.datastore.util.InstanceIdentifierUtils.toSerializable(path);
64 * @deprecated Use {@link org.opendaylight.controller.cluster.datastore.util.InstanceIdentifierUtils} instead
69 public static YangInstanceIdentifier fromSerializable(NormalizedNodeMessages.InstanceIdentifier path){
70 return org.opendaylight.controller.cluster.datastore.util.InstanceIdentifierUtils.fromSerializable(path);