@Override public Result visit(TRelationshipTemplate node, Parameter parameter) { if (Objects.isNull(node.getType())) { setInvalidDefinition(parameter); } else { validateTypeIsDefined(node.getType(), typeVisitor.getRelationshipTypes(), parameter.copy().addContext("type")); } return super.visit(node, parameter); }
/** * Converts TOSCA YAML RelationshipTemplate to TOSCA XML RelationshipTemplate Additional TOSCA YAML element * interfaces is not converted * * @param node TOSCA YAML RelationshipTemplate * @return TOSCA XML RelationshipTemplate */ private List<TRelationshipTemplate> convert(org.eclipse.winery.model.tosca.yaml.TRelationshipTemplate node, String id) { if (node == null) { return null; } List<TRelationshipTemplate> relationshipTemplates = new ArrayList<>(); int num = 0; String idName = id; while (this.relationshipSTMap.containsKey(idName)) { TRelationshipTemplate.SourceOrTargetElement sourceElement = new TRelationshipTemplate.SourceOrTargetElement(); sourceElement.setRef(this.nodeTemplateMap.get(this.relationshipSTMap.get(idName).getKey())); TRelationshipTemplate.SourceOrTargetElement targetElement = new TRelationshipTemplate.SourceOrTargetElement(); targetElement.setRef(this.nodeTemplateMap.get(this.relationshipSTMap.get(idName).getValue())); relationshipTemplates.add( new TRelationshipTemplate.Builder(idName, node.getType(), sourceElement, targetElement).build() ); idName = id + num++; } return relationshipTemplates; }
@Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof TRelationshipTemplate)) return false; TRelationshipTemplate that = (TRelationshipTemplate) o; return Objects.equals(getType(), that.getType()) && Objects.equals(getDescription(), that.getDescription()) && Objects.equals(getMetadata(), that.getMetadata()) && Objects.equals(getProperties(), that.getProperties()) && Objects.equals(getAttributes(), that.getAttributes()) && Objects.equals(getInterfaces(), that.getInterfaces()) && Objects.equals(getCopy(), that.getCopy()); }
@Override public int hashCode() { return Objects.hash(getType(), getDescription(), getMetadata(), getProperties(), getAttributes(), getInterfaces(), getCopy()); }
@Override public String toString() { return "TRelationshipTemplate{" + "type=" + getType() + ", description='" + getDescription() + '\'' + ", metadata=" + getMetadata() + ", properties=" + getProperties() + ", attributes=" + getAttributes() + ", interfaces=" + getInterfaces() + ", copy=" + getCopy() + '}'; }
public Printer visit(TRelationshipTemplate node, Parameter parameter) { return new Printer(parameter.getIndent()) .printKeyValue("type", node.getType()) .printKeyValue("description", node.getDescription()) .print(node.getMetadata().accept(this, parameter)) .print(printMap("properties", node.getProperties(), parameter)) .print(printMap("attributes", node.getAttributes(), parameter)) .print(printMap("interfaces", node.getInterfaces(), parameter)) .printKeyValue("copy", node.getCopy()); }