Search in sources :

Example 1 with YTInterfaceType

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

the class FromCanonical method convert.

public Map<String, YTInterfaceType> convert(TInterfaceType node) {
    if (Objects.isNull(node)) {
        return null;
    }
    Map<String, YTOperationDefinition> ops = new HashMap<>();
    node.getOperations().forEach((key, value) -> ops.putAll(convert(value)));
    YTInterfaceType.Builder interfaceBuilder = new YTInterfaceType.Builder().setDescription(node.getDescription()).setOperations(ops).setDerivedFrom(convert(node.getDerivedFrom(), node.getClass()));
    String typeName = node.getName();
    if (Objects.nonNull(node.getTargetNamespace()) && !node.getTargetNamespace().isEmpty()) {
        Metadata metadata = new Metadata();
        metadata.put("targetNamespace", node.getTargetNamespace());
        interfaceBuilder.addMetadata(metadata);
        if (Objects.nonNull(typeName)) {
            typeName = node.getTargetNamespace().concat(".").concat(typeName);
        }
    }
    return Collections.singletonMap(typeName, interfaceBuilder.build());
}
Also used : YTOperationDefinition(org.eclipse.winery.model.tosca.yaml.YTOperationDefinition) LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) YTInterfaceType(org.eclipse.winery.model.tosca.yaml.YTInterfaceType) Metadata(org.eclipse.winery.model.tosca.yaml.support.Metadata)

Aggregations

HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 YTInterfaceType (org.eclipse.winery.model.tosca.yaml.YTInterfaceType)1 YTOperationDefinition (org.eclipse.winery.model.tosca.yaml.YTOperationDefinition)1 Metadata (org.eclipse.winery.model.tosca.yaml.support.Metadata)1