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