@Override public String toString() { return "TRelationshipTemplate{" + "type=" + getType() + ", description='" + getDescription() + '\'' + ", metadata=" + getMetadata() + ", properties=" + getProperties() + ", attributes=" + getAttributes() + ", interfaces=" + getInterfaces() + ", copy=" + getCopy() + '}'; }
public TRelationshipTemplate build() { return new TRelationshipTemplate(this); } }
public TRelationshipTemplate(Builder builder) { this.setType(builder.type); this.setDescription(builder.description); this.setMetadata(builder.metadata); this.setAttributes(builder.attributes); this.setProperties(builder.properties); this.setInterfaces(builder.interfaces); this.setCopy(builder.copy); }
@Override public R visit(TRelationshipTemplate node, P parameter) { return reduce(Stream.of( visitElement(node.getMetadata(), parameter, "metadata"), visitElement(node.getProperties(), parameter, "properties"), visitElement(node.getAttributes(), parameter, "attributes"), visitElement(node.getInterfaces(), parameter, "interfaces") )); }
@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 int hashCode() { return Objects.hash(getType(), getDescription(), getMetadata(), getProperties(), getAttributes(), getInterfaces(), getCopy()); }
@Nullable public TRelationshipTemplate buildRelationshipTemplate(Object object, Parameter<TRelationshipTemplate> parameter) { if (Objects.isNull(object)) return new TRelationshipTemplate(); if (!validate(TRelationshipTemplate.class, object, parameter)) return null; @SuppressWarnings("unchecked") Map<String, Object> map = (Map<String, Object>) object; return new TRelationshipTemplate.Builder(buildQName(stringValue(map.get("type")))) .setDescription(buildDescription(map.get("description"))) .setMetadata(buildMetadata(map.get("metadata"))) .setProperties(buildMap(map, "properties", this::buildPropertyAssignment, parameter)) .setAttributes(buildMap(map, "attributes", this::buildAttributeAssignment, parameter)) .setInterfaces(buildMap(map.get("interfaces"), new Parameter<TInterfaceDefinition>(parameter.getContext()).addContext("interfaces") .setValue("TRelationshipTemplate") .setBuilderOO(this::buildInterfaceDefinition) )) .setCopy(buildQName(stringValue(map.get("copy")))) .build(); }
@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()); }
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()); }