Sync Integ to Master
[sdc.git] / common-be / src / main / java / org / openecomp / sdc / be / datatypes / enums / ResourceTypeEnum.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.openecomp.sdc.be.datatypes.enums;
22
23 /**
24  * Resource Type Enum
25  * @author mshitrit
26  *
27  */
28 public enum ResourceTypeEnum {
29
30         VFC("VFC"/* (Virtual Function Component)"*/, true),
31         VF("VF"/* (Virtual Function)" */, false),
32         CR("CR"/* (Complex Resource"*/, false),
33         CP("CP"/* (Connection Point)"*/, true),
34         PNF("PNF"/* (Physical Network Function)" */, false),
35         CVFC("CVFC"/* Complex Virtual Function Component*/, false),
36         VL("VL"/* (Virtual Link)"*/, true),
37         VFCMT("VFCMT"/* (VFC Monitoring Template)"*/, true),
38         Configuration("Configuration ()", true),
39         ServiceProxy("ServiceProxy ()", true),
40         ABSTRACT("Abstract (Generic VFC/VF/PNF/Service Type)", true);
41
42         private String value;
43         private boolean isAtomicType;
44
45         private ResourceTypeEnum(String value, boolean isAtomicType) {
46                 this.value = value;
47                 this.isAtomicType = isAtomicType;
48         }
49
50         public String getValue() {
51                 return value;
52         }
53
54         public boolean isAtomicType() {
55                 return isAtomicType;
56         }
57
58         public static ResourceTypeEnum getType(String type) {
59                 for (ResourceTypeEnum e : ResourceTypeEnum.values()) {
60                         if (e.name().equals(type)) {
61                                 return e;
62                         }
63                 }
64                 return null;
65         }
66
67         public static ResourceTypeEnum getTypeByName(String type) {
68                 for (ResourceTypeEnum e : ResourceTypeEnum.values()) {
69                         if (e.name().equalsIgnoreCase(type)) {
70                                 return e;
71                         }
72                 }
73                 return null;
74         }
75
76         /**
77          * Returns ResourceTypeEnum matching to received String ignore case
78          *
79          * @param type
80          * @return
81          */
82         public static ResourceTypeEnum getTypeIgnoreCase(String type) {
83                 for (ResourceTypeEnum e : ResourceTypeEnum.values()) {
84                         if (e.name().toLowerCase().equals(type.toLowerCase())) {
85                                 return e;
86                         }
87                 }
88                 return null;
89         }
90
91         /**
92          * Checks if enum exist with given type
93          *
94          * @param type
95          * @return
96          */
97         public static boolean containsName(String type) {
98
99                 for (ResourceTypeEnum e : ResourceTypeEnum.values()) {
100                         if (e.name().equals(type)) {
101                                 return true;
102                         }
103                 }
104                 return false;
105         }
106
107         /**
108          * Checks if enum exist with given type ignore case
109          *
110          * @param type
111          * @return
112          */
113         public static boolean containsIgnoreCase(String type) {
114
115                 for (ResourceTypeEnum e : ResourceTypeEnum.values()) {
116                         if (e.name().toLowerCase().equals(type.toLowerCase())) {
117                                 return true;
118                         }
119                 }
120                 return false;
121         }
122
123 }