Catalog alignment
[sdc.git] / catalog-model / src / main / java / org / openecomp / sdc / be / model / heat / HeatParameterType.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.be.model.heat;
22
23 import org.openecomp.sdc.be.model.tosca.converters.*;
24 import org.openecomp.sdc.be.model.tosca.validators.*;
25
26 public enum HeatParameterType {
27
28     STRING("string", HeatStringValidator.getInstance(), HeatStringConverter.getInstance()),
29
30     BOOLEAN("boolean", HeatBooleanValidator.getInstance(), HeatBooleanConverter.getInstance()),
31
32     NUMBER("number", HeatNumberValidator.getInstance(), HeatNumberConverter.getInstance()),
33
34     JSON("json", HeatStringValidator.getInstance(), HeatJsonConverter.getInstance()),
35
36     COMMA_DELIMITED_LIST("comma_delimited_list", HeatCommaDelimitedListValidator.getInstance(),
37             HeatCommaDelimitedListConverter.getInstance());
38
39     private String type;
40     private PropertyTypeValidator validator;
41     private PropertyValueConverter converter;
42
43     HeatParameterType(String type, PropertyTypeValidator validator, PropertyValueConverter converter) {
44         this.type = type;
45         this.validator = validator;
46         this.converter = converter;
47     }
48
49     public String getType() {
50         return type;
51     }
52
53     public PropertyTypeValidator getValidator() {
54         return validator;
55     }
56
57     public PropertyValueConverter getConverter() {
58         return converter;
59     }
60
61     public static HeatParameterType isValidType(String typeName) {
62         if (typeName == null) {
63             return null;
64         }
65
66         for (HeatParameterType type : HeatParameterType.values()) {
67             if (type.getType().equals(typeName)) {
68                 return type;
69             }
70         }
71         return null;
72     }
73 }