Create list-node elements (part1): CPS service and persistence layers
[cps.git] / cps-service / src / main / java / org / onap / cps / spi / exceptions / AlreadyDefinedException.java
index 9e54f34..1352a9b 100644 (file)
@@ -19,6 +19,8 @@
 
 package org.onap.cps.spi.exceptions;
 
+import java.util.Collection;
+
 /**
  * Already defined exception. Indicates the cps object with same name already exists.
  */
@@ -70,4 +72,10 @@ public class AlreadyDefinedException extends CpsAdminException {
         final Throwable cause) {
         return new AlreadyDefinedException("Data node", xpath, contextName, cause);
     }
+
+    public static AlreadyDefinedException forDataNodes(final Collection<String> xpaths, final String contextName,
+        final Throwable cause) {
+        final var name = String.format("(one or more) of %s", xpaths);
+        return new AlreadyDefinedException("Data node", name, contextName, cause);
+    }
 }