[VID-15] missed adding ModelUtil.java 47/4947/1
authorjimmydot <jf2512@att.com>
Fri, 9 Jun 2017 16:22:15 +0000 (12:22 -0400)
committerjimmydot <jf2512@att.com>
Fri, 9 Jun 2017 16:22:15 +0000 (12:22 -0400)
Change-Id: I24ad8f720f23a246175560e33d2455d0ab61d328
Signed-off-by: jimmydot <jf2512@att.com>
vid-app-common/src/main/java/org/openecomp/vid/model/ModelUtil.java [new file with mode: 0755]

diff --git a/vid-app-common/src/main/java/org/openecomp/vid/model/ModelUtil.java b/vid-app-common/src/main/java/org/openecomp/vid/model/ModelUtil.java
new file mode 100755 (executable)
index 0000000..4606aa0
--- /dev/null
@@ -0,0 +1,61 @@
+/*-\r
+ * ============LICENSE_START=======================================================\r
+ * VID\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ *      http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+package org.openecomp.vid.model;\r
+\r
+/**\r
+ * The Class ModelUtil.\r
+ *\r
+ */\r
+public class ModelUtil {\r
+       /**\r
+        * Gets the tags for the given element according to the configured namespace\r
+        * @param namespaces the namespace list from the configuration\r
+        * @param constantValue the constant portion of the tag name, i.e. resource.vf...\r
+        * @return the tags\r
+        */\r
+       public static String[] getTags ( String[] namespaces, String constantValue ) {\r
+               String[] tags;\r
+               if ( namespaces == null || namespaces.length == 0 ) {\r
+                       return null;\r
+               }\r
+               int le = namespaces.length;\r
+               tags = new String[le];\r
+               for ( int i = 0; i < le; i++ ) {\r
+                       tags[i] = namespaces[i] + constantValue;\r
+               }\r
+               return (tags);\r
+       }\r
+       /**\r
+        * Determine if a note template type matches a set of configurable tags\r
+        * @param type the node template type\r
+        * @param tags the model configurable namespaces\r
+        * @return true if type starts with a tag in the array, false otherwise\r
+        */\r
+       public static boolean isType ( String type, String[] tags ) {\r
+               if ( (tags != null) && (tags.length > 0) ) {\r
+                       for ( int i = 0; i < tags.length; i++ ) {\r
+                               if ( type.startsWith (tags[i]) ) {\r
+                                       return (true);\r
+                               }\r
+                       }\r
+               }\r
+               return (false);\r
+       }\r
+}\r