re base code
[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 void setType(String type) {
54         this.type = type;
55     }
56
57     public PropertyTypeValidator getValidator() {
58         return validator;
59     }
60
61     public void setValidator(PropertyTypeValidator validator) {
62         this.validator = validator;
63     }
64
65     public PropertyValueConverter getConverter() {
66         return converter;
67     }
68
69     public void setConverter(PropertyValueConverter converter) {
70         this.converter = converter;
71     }
72
73     public static HeatParameterType isValidType(String typeName) {
74         if (typeName == null) {
75             return null;
76         }
77
78         for (HeatParameterType type : HeatParameterType.values()) {
79             if (type.getType().equals(typeName)) {
80                 return type;
81             }
82         }
83         return null;
84     }
85 }