@Override public String toString() { return "TOperationDefinition{" + "description='" + getDescription() + '\'' + ", inputs=" + getInputs() + ", outputs=" + getOutputs() + ", implementation=" + getImplementation() + '}'; }
public TOperationDefinition build() { return new TOperationDefinition(this); } }
public TOperationDefinition(Builder builder) { this.setDescription(builder.description); this.setInputs(builder.inputs); this.setOutputs(builder.outputs); this.setImplementation(builder.implementation); }
private TOperation convert(TOperationDefinition node, String id) { return new TOperation.Builder(id) .addDocumentation(node.getDescription()) .addInputParameters(convertParameters(node.getInputs())) .addOutputParameters(convertParameters(node.getOutputs())) .build(); }
@Override public R visit(TOperationDefinition node, P parameter) { return reduce(Stream.of( visitElement(node.getInputs(), parameter, "inputs"), visitElement(node.getImplementation(), parameter, "implementation") )); }
@Override public Result visit(TInterfaceType node, Parameter parameter) { if (Objects.nonNull(node.getOperations())) { for (Map.Entry<String, TOperationDefinition> entry : node.getOperations().entrySet()) { if (Objects.nonNull(entry.getValue().getImplementation())) { setException(new InvalidToscaSyntax( "The InterfaceType '{}' MUST NOT include any implementations for defined operations", parameter.getKey() ).setContext(parameter.getContext()) ); } } } return super.visit(node, parameter); }
/** * Inserts operation output definitions defined in attributes "{ get_operation_output: [ SELF, interfaceName, * operationName, propertyName ] }" into interfaceDefinitions */ private Map<String, TInterfaceDefinition> refactor(Map<String, TInterfaceDefinition> map, org.eclipse.winery.model.tosca.yaml.TNodeType node) { if (Objects.isNull(map) || map.isEmpty() || node.getAttributes().isEmpty()) return map; // Extract Outputs from Attributes and attach them to the Operations (if possible) // Template: attribute.default: { get_operation_output: [ SELF, interfaceName, operationName, propertyName ] } for (Map.Entry<String, TAttributeDefinition> entry : node.getAttributes().entrySet()) { TAttributeDefinition attr = entry.getValue(); if (attr.getDefault() != null && attr.getDefault() instanceof Map) { @SuppressWarnings("unchecked") Map<String, Object> aDefault = (Map<String, Object>) attr.getDefault(); if (aDefault != null && aDefault.containsKey("get_operation_output")) { @SuppressWarnings("unchecked") List<String> values = (List<String>) aDefault.get("get_operation_output"); if (values.size() == 4 && values.get(0).equals("SELF") && map.containsKey(values.get(1)) && map.get(values.get(1)).getOperations().containsKey(values.get(2)) && !map.get(values.get(1)).getOperations().get(values.get(2)).getOutputs().containsKey(values.get(3)) ) { TPropertyDefinition.Builder pBuilder = new TPropertyDefinition.Builder(attr.getType()); map.get(values.get(1)).getOperations().get(values.get(2)).getOutputs().put(values.get(3), pBuilder.build()); } } } } return map; }
entry.getValue().getOperations() .entrySet().stream() .filter(operation -> operation.getValue() != null && operation.getValue().getImplementation() != null) .forEach(operation -> { String interfaceName = entry.getKey(); String operationName = operation.getKey(); TImplementation implementation = operation.getValue().getImplementation(); List<QName> list = implementation.getDependencies(); if (implementation.getPrimary() != null) {
@Override public int hashCode() { return Objects.hash(getDescription(), getInputs(), getOutputs(), getImplementation()); }
@Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof TOperationDefinition)) return false; TOperationDefinition that = (TOperationDefinition) o; return Objects.equals(getDescription(), that.getDescription()) && Objects.equals(getInputs(), that.getInputs()) && Objects.equals(getOutputs(), that.getOutputs()) && Objects.equals(getImplementation(), that.getImplementation()); }
public Printer visit(TOperationDefinition node, Parameter parameter) { return new Printer(parameter.getIndent()) .printKeyValue("description", node.getDescription()) .print(printMap("inputs", node.getInputs(), new Parameter(parameter.getIndent()))) .print(printMap("outputs", node.getOutputs(), new Parameter(parameter.getIndent()))) .print(printVisitorNode(node.getImplementation(), new Parameter(parameter.getIndent()).addContext("implementation"))); }