Fetching data node by xpath - persistence layer
[cps.git] / cps-service / src / main / java / org / onap / cps / spi / model / DataNodeBuilder.java
index d187f62..67e93dd 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2021 Bell Canada. All rights reserved.
+ *  Modifications Copyright (C) 2021 Pantheon.tech
  *  ================================================================================
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -42,6 +43,7 @@ public class DataNodeBuilder {
 
     private NormalizedNode<?, ?> normalizedNodeTree;
     private String xpath;
+    private Map<String, Object> leaves = Collections.emptyMap();
     private Collection<DataNode> childDataNodes = Collections.emptySet();
 
 
@@ -67,6 +69,17 @@ public class DataNodeBuilder {
         return this;
     }
 
+    /**
+     * To use attributes for creating {@link DataNode}.
+     *
+     * @param leaves for the data node
+     * @return DataNodeBuilder
+     */
+    public DataNodeBuilder withLeaves(final Map<String, Object> leaves) {
+        this.leaves = leaves;
+        return this;
+    }
+
     /**
      * To specify child nodes needs to be used while creating {@link DataNode}.
      *
@@ -96,6 +109,7 @@ public class DataNodeBuilder {
     private DataNode buildFromAttributes() {
         final DataNode dataNode = new DataNode();
         dataNode.setXpath(xpath);
+        dataNode.setLeaves(leaves);
         dataNode.setChildDataNodes(childDataNodes);
         return dataNode;
     }