40253ad1bedf1016233f390511a34f7c4266720d
[sdc.git] /
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.heat.datatypes.model;
22
23 import java.util.HashMap;
24 import java.util.Map;
25 import java.util.Objects;
26
27 public enum ContrailV2ResourceTypes {
28     NETWROK_IPAM("OS::ContrailV2::NetworkIpam"),
29     VIRTUAL_NETWORK("OS::ContrailV2::VirtualNetwork"),
30     NETWORK_POLICY("OS::ContrailV2::NetworkPolicy"),
31     VIRTUAL_MACHINE_INTERFACE("OS::ContrailV2::VirtualMachineInterface");
32
33     private static Map<String, ContrailV2ResourceTypes> stringToContrailV2ResourceTypeMap;
34
35     static {
36         stringToContrailV2ResourceTypeMap = new HashMap<>();
37
38         for (ContrailV2ResourceTypes type : ContrailV2ResourceTypes.values()) {
39             stringToContrailV2ResourceTypeMap.put(type.contrailV2ResourceType, type);
40         }
41     }
42
43     private String contrailV2ResourceType;
44
45     ContrailV2ResourceTypes(String contrailV2ResourceType) {
46         this.contrailV2ResourceType = contrailV2ResourceType;
47     }
48
49     public static ContrailV2ResourceTypes findByContrailV2Resource(String contrailV2Resource) {
50         return stringToContrailV2ResourceTypeMap.get(contrailV2Resource);
51     }
52
53     public static boolean isResourceTypeContrailV2(String resourceType) {
54         return Objects.nonNull(findByContrailV2Resource(resourceType));
55     }
56
57     public String getContrailV2ResourceType() {
58         return contrailV2ResourceType;
59     }
60 }