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;
19 import java.util.Collections;
20 import java.util.HashMap;
21 import java.util.HashSet;
25 public enum PropertyType {
31 TIMESTAMP("timestamp"),
35 SCALAR_UNIT_SIZE("scalar-unit.size"),
36 SCALAR_UNIT_FREQUENCY("scalar-unit.frequency");
38 private static final Map<String, PropertyType> mMap =
39 Collections.unmodifiableMap(initializeMapping());
40 private static final Set<String> simplePropertyTypes =
41 Collections.unmodifiableSet(initializeSimplePropertyTypes());
42 private String displayName;
44 PropertyType(String displayName) {
46 this.displayName = displayName;
50 * Initilize property type display name mapping.
53 public static Map<String, PropertyType> initializeMapping() {
54 Map<String, PropertyType> typeMap = new HashMap<>();
55 for (PropertyType v : PropertyType.values()) {
56 typeMap.put(v.displayName, v);
62 * Get Property type by display name.
64 * @return PropertyType
66 public static PropertyType getPropertyTypeByDisplayName(String displayName) {
70 if (mMap.containsKey(displayName)) {
71 return mMap.get(displayName);
76 private static Set<String> initializeSimplePropertyTypes() {
77 Set<String> simplePropertyTypes = new HashSet<>(4);
78 simplePropertyTypes.add(STRING.getDisplayName().toLowerCase());
79 simplePropertyTypes.add(INTEGER.getDisplayName().toLowerCase());
80 simplePropertyTypes.add(FLOAT.getDisplayName().toLowerCase());
81 simplePropertyTypes.add(BOOLEAN.getDisplayName().toLowerCase());
82 return simplePropertyTypes;
85 public static Set<String> getSimplePropertyTypes() {
86 return simplePropertyTypes;
89 public String getDisplayName() {