push addional code
[sdc.git] / openecomp-be / lib / openecomp-tosca-lib / src / main / java / org / openecomp / sdc / tosca / datatypes / model / heatextend / PropertyTypeExt.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.tosca.datatypes.model.heatextend;
22
23 import java.util.Collections;
24 import java.util.HashMap;
25 import java.util.Map;
26
27 /**
28  * The enum Property type ext.
29  */
30 public enum PropertyTypeExt {
31
32   /**
33    * Json property type ext.
34    */
35   JSON("json");
36
37   private static final Map<String, PropertyTypeExt> mMap =
38       Collections.unmodifiableMap(initializeMapping());
39   private String displayName;
40
41   PropertyTypeExt(String displayName) {
42
43     this.displayName = displayName;
44   }
45
46   /**
47    * Initialize mapping map.
48    *
49    * @return the map
50    */
51   public static Map<String, PropertyTypeExt> initializeMapping() {
52     Map<String, PropertyTypeExt> typeMap = new HashMap<String, PropertyTypeExt>();
53     for (PropertyTypeExt v : PropertyTypeExt.values()) {
54       typeMap.put(v.displayName, v);
55     }
56     return typeMap;
57   }
58
59   /**
60    * Gets property type by display name.
61    *
62    * @param displayName the display name
63    * @return the property type by display name
64    */
65   public static PropertyTypeExt getPropertyTypeByDisplayName(String displayName) {
66     if (mMap == null) {
67       initializeMapping();
68     }
69     if (mMap.containsKey(displayName)) {
70       return mMap.get(displayName);
71     }
72     return null;
73   }
74
75   /**
76    * Gets display name.
77    *
78    * @return the display name
79    */
80   public String getDisplayName() {
81     return displayName;
82   }
83
84
85 }