Changing default path separator to "|" to unblock dynamic config demo.

Change-Id: I154f369d71ceee26bde6516a978f332a15d389e5
diff --git a/core/api/src/main/java/org/onosproject/store/service/DocumentPath.java b/core/api/src/main/java/org/onosproject/store/service/DocumentPath.java
index ada10b8..0a4906e 100644
--- a/core/api/src/main/java/org/onosproject/store/service/DocumentPath.java
+++ b/core/api/src/main/java/org/onosproject/store/service/DocumentPath.java
@@ -16,24 +16,34 @@
 
 package org.onosproject.store.service;
 
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Lists;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang.StringUtils;
+
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Objects;
 
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.lang.StringUtils;
-
-import com.google.common.base.Preconditions;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Lists;
+import static com.google.common.base.Preconditions.checkNotNull;
 
 /**
  * Unique key for nodes in the {@link DocumentTree}.
  */
 public class DocumentPath implements Comparable<DocumentPath> {
 
+    /** Default path separator. */
+    public static final String DEFAULT_SEPARATOR = "|";
+
+    /** Default path separator regex. */
+    public static final String DEFAULT_SEPARATOR_RE = "\\|";
+
+    // TODO: Add means to set the path separator and separator ERE.
+    private static String pathSeparator = DEFAULT_SEPARATOR;
+    private static String pathSeparatorRE = DEFAULT_SEPARATOR_RE;
+
     private final List<String> pathElements = Lists.newArrayList();
 
     /**
@@ -42,7 +52,7 @@
      * @param pathElements list of path elements
      */
     private DocumentPath(List<String> pathElements) {
-        Preconditions.checkNotNull(pathElements);
+        checkNotNull(pathElements);
         this.pathElements.addAll(pathElements);
     }
 
@@ -58,16 +68,15 @@
      * @throws IllegalDocumentNameException if both parameters are null or name contains an illegal character ('.')
      */
     public DocumentPath(String nodeName, DocumentPath parentPath) {
-        if (nodeName.contains(".")) {
+        checkNotNull(nodeName, "Node name cannot be null");
+        if (nodeName.contains(pathSeparator)) {
             throw new IllegalDocumentNameException(
                     "Periods are not allowed in names.");
         }
         if (parentPath != null) {
             pathElements.addAll(parentPath.pathElements());
         }
-        if (nodeName != null) {
-            pathElements.add(nodeName);
-        }
+        pathElements.add(nodeName);
         if (pathElements.isEmpty()) {
             throw new IllegalDocumentNameException("A document path must contain at" +
                                                    "least one non-null" +
@@ -82,7 +91,7 @@
      * @return {@code DocumentPath} instance
      */
     public static DocumentPath from(String path) {
-        return new DocumentPath(Arrays.asList(path.split("\\.")));
+        return new DocumentPath(Arrays.asList(path.split(pathSeparatorRE)));
     }
 
     /**
@@ -179,7 +188,7 @@
         while (iter.hasNext()) {
             stringBuilder.append(iter.next());
             if (iter.hasNext()) {
-                stringBuilder.append(".");
+                stringBuilder.append(pathSeparator);
             }
         }
         return stringBuilder.toString();
diff --git a/core/api/src/test/java/org/onosproject/store/service/DocumentPathTest.java b/core/api/src/test/java/org/onosproject/store/service/DocumentPathTest.java
index 2c0197b..71b274f 100644
--- a/core/api/src/test/java/org/onosproject/store/service/DocumentPathTest.java
+++ b/core/api/src/test/java/org/onosproject/store/service/DocumentPathTest.java
@@ -31,22 +31,26 @@
 
     @Test
     public void testConstruction() {
-        DocumentPath path = DocumentPath.from("root.a.b");
+        DocumentPath path = path("root.a.b");
         assertEquals(path.pathElements(), Arrays.asList("root", "a", "b"));
-        assertEquals(DocumentPath.from("root.a"), path.parent());
+        assertEquals(path("root.a"), path.parent());
     }
 
     @Test
     public void testAncestry() {
-        DocumentPath path1 = DocumentPath.from("root.a.b");
-        DocumentPath path2 = DocumentPath.from("root.a.d");
-        DocumentPath path3 = DocumentPath.from("root.a.b.c");
+        DocumentPath path1 = path("root.a.b");
+        DocumentPath path2 = path("root.a.d");
+        DocumentPath path3 = path("root.a.b.c");
         DocumentPath lca = DocumentPath.leastCommonAncestor(Arrays.asList(path1, path2, path3));
-        assertEquals(DocumentPath.from("root.a"), lca);
+        assertEquals(path("root.a"), lca);
         assertTrue(path1.isAncestorOf(path3));
         assertFalse(path1.isAncestorOf(path2));
         assertTrue(path3.isDescendentOf(path3));
         assertTrue(path3.isDescendentOf(path1));
         assertFalse(path3.isDescendentOf(path2));
     }
+
+    private static DocumentPath path(String path) {
+        return DocumentPath.from(path.replace(".", DocumentPath.DEFAULT_SEPARATOR));
+    }
 }