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