2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2019 Nordix Foundation
4 * ================================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * 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.
16 * SPDX-License-Identifier: Apache-2.0
17 * ============LICENSE_END=========================================================
20 package org.openecomp.core.converter.impl.pnfd.parser;
23 import org.onap.sdc.tosca.datatypes.model.EntrySchema;
24 import org.onap.sdc.tosca.datatypes.model.ParameterDefinition;
25 import org.onap.sdc.tosca.datatypes.model.Status;
28 * Handles YAML from/to {@link ParameterDefinition} conversions
30 public class ParameterDefinitionYamlParser {
32 private ParameterDefinitionYamlParser() {
36 * Parses the given a YAML object to a {@link ParameterDefinition} instance.
37 * @param parameterDefinitionYaml the YAML object representing a TOSCA Parameter Definition
39 * A new instance of {@link ParameterDefinition}.
41 public static ParameterDefinition parse(final Map<String, Object> parameterDefinitionYaml) {
42 final ParameterDefinition parameterDefinition = new ParameterDefinition();
43 parameterDefinition.set_default(parameterDefinitionYaml.get("default"));
44 parameterDefinition.setDescription((String) parameterDefinitionYaml.get("description"));
45 final Map<String, Object> entrySchemaYaml = (Map<String, Object>) parameterDefinitionYaml.get("entry_schema");
46 if (entrySchemaYaml != null) {
47 final EntrySchema entrySchema = new EntrySchema();
48 entrySchema.setType((String) entrySchemaYaml.get("type"));
49 parameterDefinition.setEntry_schema(entrySchema);
51 parameterDefinition.setRequired((Boolean) parameterDefinitionYaml.get("required"));
52 parameterDefinition.setType((String) parameterDefinitionYaml.get("type"));
53 parameterDefinition.setStatus((Status) parameterDefinitionYaml.get("status"));
55 return parameterDefinition;