7538f11593c409fab783c14af0e4ed23d6665424
[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 ContrailResourceTypes {
28     ATTACH_POLICY("OS::Contrail::AttachPolicy"),
29     SERVICE_INSTANCE("OS::Contrail::ServiceInstance"),
30     SERVICE_TEMPLATE("OS::Contrail::ServiceTemplate"),
31     NETWORK_POLICY("OS::Contrail::NetworkPolicy"),
32     VIRTUAL_NETWORK("OS::Contrail::VirtualNetwork");
33
34     private static Map<String, ContrailResourceTypes> stringToContrailResourceTypeMap;
35
36     static {
37         stringToContrailResourceTypeMap = new HashMap<>();
38
39         for (ContrailResourceTypes type : ContrailResourceTypes.values()) {
40             stringToContrailResourceTypeMap.put(type.contrailResourceType, type);
41         }
42     }
43
44     private String contrailResourceType;
45
46     ContrailResourceTypes(String contrailResourceType) {
47         this.contrailResourceType = contrailResourceType;
48     }
49
50     /**
51      * Find by contrail v 2 resource contrail resource types.
52      *
53      * @param contrailV2Resource the contrail v 2 resource
54      * @return the contrail resource types
55      */
56     public static ContrailResourceTypes findByContrailV2Resource(String contrailV2Resource) {
57         return contrailV2Resource == null ? null
58                 : stringToContrailResourceTypeMap.get(contrailV2Resource);
59
60     }
61
62     public static boolean isResourceTypeContrail(String resourceType) {
63         return Objects.nonNull(findByContrailV2Resource(resourceType));
64     }
65
66     public String getContrailResourceType() {
67         return contrailResourceType;
68     }
69 }