Upgrade sonar plugin
[vid.git] / vid-app-common / src / main / java / org / openecomp / vid / model / ModelUtil.java
1 /**
2  * 
3  */
4 package org.openecomp.vid.model;
5
6 /**
7  * The Class ModelUtil.
8  *
9  */
10 public class ModelUtil {
11         /**
12          * Gets the tags for the given element according to the configured namespace
13          * @param namespaces the namespace list from the configuration
14          * @param constantValue the constant portion of the tag name, i.e. resource.vf...
15          * @return the tags
16          */
17         public static String[] getTags ( String[] namespaces, String constantValue ) {
18                 String[] tags;
19                 if ( namespaces == null || namespaces.length == 0 ) {
20                         return null;
21                 }
22                 int le = namespaces.length;
23                 tags = new String[le];
24                 for ( int i = 0; i < le; i++ ) {
25                         tags[i] = namespaces[i] + constantValue;
26                 }
27                 return (tags);
28         }
29         /**
30          * Determine if a note template type matches a set of configurable tags
31          * @param type the node template type
32          * @param tags the model configurable namespaces
33          * @return true if type starts with a tag in the array, false otherwise
34          */
35         public static boolean isType ( String type, String[] tags ) {
36                 if ( (tags != null) && (tags.length > 0) ) {
37                         for ( int i = 0; i < tags.length; i++ ) {
38                                 if ( type.startsWith (tags[i]) ) {
39                                         return (true);
40                                 }
41                         }
42                 }
43                 return (false);
44         }
45 }