@Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof TInterfaceType)) return false; if (!super.equals(o)) return false; TInterfaceType that = (TInterfaceType) o; return Objects.equals(getOperations(), that.getOperations()) && Objects.equals(getInputs(), that.getInputs()); }
@Override public int hashCode() { return Objects.hash(super.hashCode(), getOperations(), getInputs()); }
@Override public String toString() { return "TInterfaceType{" + "operations=" + getOperations() + ", inputs=" + getInputs() + "} " + super.toString(); }
@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); }
@Override public R visit(TInterfaceType node, P parameter) { return reduce(Stream.of( visitElement(node.getInputs(), parameter, "inputs"), visitElement(node.getOperations(), parameter, "operations") )); }
public Printer visit(TInterfaceType node, Parameter parameter) { return new Printer(parameter.getIndent()) .print(node.getOperations().entrySet().stream() .map(entry -> printVisitorNode(entry.getValue(), new Parameter(parameter.getIndent()).addContext(entry.getKey())) ) .reduce(Printer::print) ) .print(printMap("inputs", node.getInputs(), parameter)); }
/** * 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(); }