@Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof TNodeType)) return false; if (!super.equals(o)) return false; TNodeType tNodeType = (TNodeType) o; return Objects.equals(getAttributes(), tNodeType.getAttributes()) && Objects.equals(getRequirements(), tNodeType.getRequirements()) && Objects.equals(getCapabilities(), tNodeType.getCapabilities()) && Objects.equals(getInterfaces(), tNodeType.getInterfaces()) && Objects.equals(getArtifacts(), tNodeType.getArtifacts()); }
/** * 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 int hashCode() { return Objects.hash(super.hashCode(), getAttributes(), getRequirements(), getCapabilities(), getInterfaces(), getArtifacts()); }
@Override public String toString() { return "TNodeType{" + "attributes=" + getAttributes() + ", requirements=" + getRequirements() + ", capabilities=" + getCapabilities() + ", interfaces=" + getInterfaces() + ", artifacts=" + getArtifacts() + "} " + super.toString(); }
public Printer visit(TNodeType node, Parameter parameter) { return new Printer(parameter.getIndent()) .print(printMap("attributes", node.getAttributes(), parameter)) .print(printListMap("requirements", node.getRequirements().stream().map(TMapRequirementDefinition::getMap).collect(Collectors.toList()), parameter)) .print(printMap("capabilities", node.getCapabilities(), parameter)) .print(printMap("interfaces", node.getInterfaces(), parameter)) .print(printMap("artifacts", node.getArtifacts(), parameter)); }