@Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof TPolicyDefinition)) return false; TPolicyDefinition that = (TPolicyDefinition) o; return Objects.equals(getType(), that.getType()) && Objects.equals(getDescription(), that.getDescription()) && Objects.equals(getMetadata(), that.getMetadata()) && Objects.equals(getProperties(), that.getProperties()) && Objects.equals(getTargets(), that.getTargets()); }
@Override public R visit(TPolicyDefinition node, P parameter) { return reduce(Stream.of( visitElement(node.getMetadata(), parameter, "metadata"), visitElement(node.getProperties(), parameter, "properties") )); }
@Override public int hashCode() { return Objects.hash(getType(), getDescription(), getMetadata(), getProperties(), getTargets()); }
@Override public String toString() { return "TPolicyDefinition{" + "type=" + getType() + ", description='" + getDescription() + '\'' + ", metadata=" + getMetadata() + ", properties=" + getProperties() + ", targets=" + getTargets() + '}'; }
/** * Converts TOSCA YAML PolicyDefinitions to TOSCA XML Policy and PolicyTemplate Additional TOSCA YAML element * trigger is not converted * * @param node TOSCA YAML PolicyDefinition */ private void convert(TPolicyDefinition node, String id) { if (node == null) { return; } TPolicyTemplate.Builder builder = new TPolicyTemplate.Builder(id + "_templ", node.getType()); builder.setName(id); builder.setProperties(convertPropertyAssignments(node.getProperties(), getPropertyTypeName(node.getType()))); this.policyTemplates.add(builder.build()); TPolicy.Builder pbuilder = new TPolicy.Builder(node.getType()); pbuilder.setName(id); pbuilder.setPolicyRef(new QName(id + "_templ")); /* if PolicyDefinition has targets the resulting Policy is added to the target else its added to the * BoundaryDefinition of the Service Template */ if (node.getTargets() == null || node.getTargets().size() == 0) { this.addPolicy("boundary", pbuilder.build()); } else { for (QName target : node.getTargets()) { this.addPolicy(target.toString(), pbuilder.build()); } } }
public Printer visit(TPolicyDefinition 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)) .printKeyValue("targets", node.getTargets()); }