@Override public String toString() { return "TInterfaceDefinition{" + "type=" + getType() + ", inputs=" + getInputs() + ", operations=" + getOperations() + '}'; }
public TInterfaceDefinition build() { return new TInterfaceDefinition(this); } }
public TInterfaceDefinition(Builder builder) { this.setType(builder.type); this.setInputs(builder.inputs); this.setOperations(builder.operations); }
/** * Converts TOSCA YAML InterfaceDefinitions to TOSCA XML Interface Additional TOSCA YAML element input with * PropertyAssignment or PropertyDefinition is not converted * * @param node TOSCA YAML InterfaceDefinition * @return TOSCA XML Interface */ private TInterface convert(TInterfaceDefinition node, String id) { List<TOperation> operation = new ArrayList<>(); if (this.interfaceTypes.containsKey(node.getType())) { operation.addAll(convert(this.interfaceTypes.get(node.getType()).getOperations())); } operation.addAll(convert(node.getOperations())); TInterface.Builder builder = new TInterface.Builder(id, operation); return builder.build(); }
@Override public R visit(TInterfaceDefinition node, P parameter) { return reduce(Stream.of( visitElement(node.getInputs(), parameter, "inputs"), visitElement(node.getOperations(), parameter, "operations") )); }
/** * 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; }
@Override public String toString() { return "TInterfaceAssignment{} " + super.toString(); }
public <R extends AbstractResult<R>, P extends AbstractParameter<P>> R accept(IVisitor<R, P> visitor, P parameter) { R ir1 = super.accept(visitor, parameter); R ir2 = visitor.visit(this, parameter); if (ir1 == null) { return ir2; } else { return ir1.add(ir2); } }
entry.getValue().getOperations() .entrySet().stream() .filter(operation -> operation.getValue() != null && operation.getValue().getImplementation() != null)
@Override public int hashCode() { return Objects.hash(getType(), getInputs(), getOperations()); }
@Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof TInterfaceDefinition)) return false; TInterfaceDefinition that = (TInterfaceDefinition) o; return Objects.equals(getType(), that.getType()) && Objects.equals(getInputs(), that.getInputs()) && Objects.equals(getOperations(), that.getOperations()); }
public Printer visit(TInterfaceDefinition node, Parameter parameter) { return new Printer(parameter.getIndent()) .printKeyValue("type", node.getType()) .print(printMap("inputs", node.getInputs(), parameter)) .print(node.getOperations().entrySet().stream() .filter(entry -> Objects.nonNull(entry) && Objects.nonNull(entry.getValue())) .map(entry -> printVisitorNode(entry.getValue(), new Parameter(parameter.getIndent()).addContext(entry.getKey())) ) .reduce(Printer::print) ); }