2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.openecomp.sdc.heat.datatypes.model;
23 import java.util.HashMap;
25 import java.util.Objects;
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");
34 private static Map<String, ContrailResourceTypes> stringToContrailResourceTypeMap;
37 stringToContrailResourceTypeMap = new HashMap<>();
39 for (ContrailResourceTypes type : ContrailResourceTypes.values()) {
40 stringToContrailResourceTypeMap.put(type.contrailResourceType, type);
44 private String contrailResourceType;
46 ContrailResourceTypes(String contrailResourceType) {
47 this.contrailResourceType = contrailResourceType;
51 * Find by contrail v 2 resource contrail resource types.
53 * @param contrailV2Resource the contrail v 2 resource
54 * @return the contrail resource types
56 public static ContrailResourceTypes findByContrailV2Resource(String contrailV2Resource) {
57 return contrailV2Resource == null ? null
58 : stringToContrailResourceTypeMap.get(contrailV2Resource);
62 public static boolean isResourceTypeContrail(String resourceType) {
63 return Objects.nonNull(findByContrailV2Resource(resourceType));
66 public String getContrailResourceType() {
67 return contrailResourceType;