Search in sources :

Example 6 with YTOperationDefinition

use of org.eclipse.winery.model.tosca.yaml.YTOperationDefinition in project winery by eclipse.

the class YamlBuilder method buildOperationDefinition.

@Nullable
@SuppressWarnings("unchecked")
public YTOperationDefinition buildOperationDefinition(Object object, Parameter<YTOperationDefinition> parameter) {
    if (Objects.isNull(object) || !validate(YTOperationDefinition.class, object, parameter)) {
        return null;
    }
    if (!(object instanceof Map)) {
        return null;
    }
    Map<String, Object> map = (Map<String, Object>) object;
    String description = buildDescription(map.get(YamlSpecKeywords.DESCRIPTION));
    Map<String, YTParameterDefinition> inputs = buildParameterDefinitions(map.get(YamlSpecKeywords.INPUTS), new Parameter<>(parameter.getContext()).addContext(YamlSpecKeywords.INPUTS).setValue(parameter.getValue()));
    Map<String, YTParameterDefinition> outputs = buildParameterDefinitions(map.get(YamlSpecKeywords.OUTPUTS), new Parameter<>(parameter.getContext()).addContext(YamlSpecKeywords.OUTPUTS).setValue(parameter.getValue()));
    YTImplementation implementation = buildImplementation(map.get(YamlSpecKeywords.IMPLEMENTATION), new Parameter<YTImplementation>(parameter.getContext()).addContext(YamlSpecKeywords.IMPLEMENTATION));
    return new YTOperationDefinition.Builder().setDescription(description).setInputs(inputs).setOutputs(outputs).setImplementation(implementation).build();
}
Also used : YTOperationDefinition(org.eclipse.winery.model.tosca.yaml.YTOperationDefinition) YTMapObject(org.eclipse.winery.model.tosca.yaml.support.YTMapObject) YTParameterDefinition(org.eclipse.winery.model.tosca.yaml.YTParameterDefinition) YTListString(org.eclipse.winery.model.tosca.yaml.support.YTListString) YTImplementation(org.eclipse.winery.model.tosca.yaml.YTImplementation) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap) Nullable(org.eclipse.jdt.annotation.Nullable)

Aggregations

YTOperationDefinition (org.eclipse.winery.model.tosca.yaml.YTOperationDefinition)6 LinkedHashMap (java.util.LinkedHashMap)5 Map (java.util.Map)4 YTImplementation (org.eclipse.winery.model.tosca.yaml.YTImplementation)4 YTInterfaceDefinition (org.eclipse.winery.model.tosca.yaml.YTInterfaceDefinition)2 HashMap (java.util.HashMap)1 Nullable (org.eclipse.jdt.annotation.Nullable)1 TOperationDefinition (org.eclipse.winery.model.tosca.TOperationDefinition)1 YTInterfaceType (org.eclipse.winery.model.tosca.yaml.YTInterfaceType)1 YTParameterDefinition (org.eclipse.winery.model.tosca.yaml.YTParameterDefinition)1 Metadata (org.eclipse.winery.model.tosca.yaml.support.Metadata)1 YTListString (org.eclipse.winery.model.tosca.yaml.support.YTListString)1 YTMapObject (org.eclipse.winery.model.tosca.yaml.support.YTMapObject)1