Populate Dataspace field of DataNode
[cps.git] / cps-service / src / main / java / org / onap / cps / spi / model / DataNodeBuilder.java
index b23cdfc..e212933 100644 (file)
@@ -2,8 +2,8 @@
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2021 Bell Canada. All rights reserved.
  *  Modifications Copyright (C) 2021 Pantheon.tech
- *  Modifications Copyright (C) 2022 Nordix Foundation.
- *  Modifications Copyright (C) 2022 TechMahindra Ltd.
+ *  Modifications Copyright (C) 2022-2023 Nordix Foundation.
+ *  Modifications Copyright (C) 2022-2023 TechMahindra Ltd.
  *  ================================================================================
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -54,6 +54,8 @@ public class DataNodeBuilder {
     private String parentNodeXpath = "";
     private Map<String, Serializable> leaves = Collections.emptyMap();
     private Collection<DataNode> childDataNodes = Collections.emptySet();
+    private String dataspaceName;
+    private String anchorName;
 
     /**
      * To use parent node xpath for creating {@link DataNode}.
@@ -88,6 +90,28 @@ public class DataNodeBuilder {
         return this;
     }
 
+    /**
+     * To use dataspace name for creating {@link DataNode}.
+     *
+     * @param dataspaceName dataspace name for the data node
+     * @return DataNodeBuilder
+     */
+    public DataNodeBuilder withDataspace(final String dataspaceName) {
+        this.dataspaceName = dataspaceName;
+        return this;
+    }
+
+    /**
+     * To use anchor name for creating {@link DataNode}.
+     *
+     * @param anchorName anchor name for the data node
+     * @return DataNodeBuilder
+     */
+    public DataNodeBuilder withAnchor(final String anchorName) {
+        this.anchorName = anchorName;
+        return this;
+    }
+
     /**
      * To use module name for prefix for creating {@link DataNode}.
      *
@@ -153,6 +177,8 @@ public class DataNodeBuilder {
         dataNode.setModuleNamePrefix(moduleNamePrefix);
         dataNode.setLeaves(leaves);
         dataNode.setChildDataNodes(childDataNodes);
+        dataNode.setDataspace(dataspaceName);
+        dataNode.setAnchorName(anchorName);
         return dataNode;
     }