2 * Copyright © 2016-2018 European Support Limited
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.onap.sdc.tosca.datatypes.model;
20 public enum PropertyType {
26 TIMESTAMP("timestamp"),
30 SCALAR_UNIT_SIZE("scalar-unit.size"),
31 SCALAR_UNIT_FREQUENCY("scalar-unit.frequency");
33 private static final Map<String, PropertyType> M_MAP =
34 Collections.unmodifiableMap(initializeMapping());
35 private static final Set<String> SIMPLE_PROPERTY_TYPES =
36 Collections.unmodifiableSet(initializeSimplePropertyTypes());
37 private String displayName;
39 PropertyType(String displayName) {
41 this.displayName = displayName;
45 * Initilize property type display name mapping.
48 public static Map<String, PropertyType> initializeMapping() {
49 Map<String, PropertyType> typeMap = new HashMap<>();
50 for (PropertyType v : PropertyType.values()) {
51 typeMap.put(v.displayName, v);
57 * Get Property type by display name.
59 * @return PropertyType
61 public static PropertyType getPropertyTypeByDisplayName(String displayName) {
62 if (M_MAP.containsKey(displayName)) {
63 return M_MAP.get(displayName);
68 private static Set<String> initializeSimplePropertyTypes() {
69 final int setSize = 4;
70 Set<String> simplePropertyTypes = new HashSet<>(setSize);
71 simplePropertyTypes.add(STRING.getDisplayName().toLowerCase());
72 simplePropertyTypes.add(INTEGER.getDisplayName().toLowerCase());
73 simplePropertyTypes.add(FLOAT.getDisplayName().toLowerCase());
74 simplePropertyTypes.add(BOOLEAN.getDisplayName().toLowerCase());
75 return simplePropertyTypes;
78 public static Set<String> getSimplePropertyTypes() {
79 return SIMPLE_PROPERTY_TYPES;
82 public String getDisplayName() {