* ============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.
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}.
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}.
*
dataNode.setModuleNamePrefix(moduleNamePrefix);
dataNode.setLeaves(leaves);
dataNode.setChildDataNodes(childDataNodes);
+ dataNode.setDataspace(dataspaceName);
+ dataNode.setAnchorName(anchorName);
return dataNode;
}
private DataNode buildFromContainerNode() {
final Collection<DataNode> dataNodeCollection = buildCollectionFromContainerNode();
- if (!dataNodeCollection.iterator().hasNext()) {
- throw new DataValidationException(
- "Unsupported xpath: ", "Unsupported xpath as it is referring to one element");
+ if (dataNodeCollection.isEmpty()) {
+ throw new DataValidationException("Unsupported Normalized Node", "No valid node found");
}
return dataNodeCollection.iterator().next();
}
}
}
-
}