@Override public String toString() { return "TAttributeDefinition{" + "description='" + getDescription() + '\'' + ", type=" + getType() + ", defaultValue=" + getDefault() + ", status=" + getStatus() + ", entrySchema=" + getEntrySchema() + '}'; }
public TAttributeDefinition build() { return new TAttributeDefinition(this); } }
public TAttributeDefinition(Builder builder) { this.setType(builder.type); this.setDescription(builder.description); this.setDefault(builder.defaultValue); this.setStatus(builder.status); this.setEntrySchema(builder.entrySchema); }
/** * 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 Result visit(TAttributeDefinition node, Parameter parameter) { validatePropertyOrAttributeDefinition(node.getType(), node.getEntrySchema(), parameter); return super.visit(node, parameter); } }
@Override public R visit(TAttributeDefinition node, P parameter) { return visitElement(node.getEntrySchema(), parameter, "entry_schema"); }
@Override public int hashCode() { return Objects.hash(getDescription(), getType(), getDefault(), getStatus(), getEntrySchema()); }
@Nullable public <T> TAttributeDefinition buildAttributeDefinition(Object object, Parameter<T> parameter) { if (Objects.isNull(object)) return new TAttributeDefinition(); if (!validate(TAttributeDefinition.class, object, parameter)) return null; @SuppressWarnings("unchecked") Map<String, Object> map = (Map<String, Object>) object; return new TAttributeDefinition.Builder(buildQName(stringValue(map.get("type")))) .setDescription(buildDescription(map.get("description"))) .setDefault(map.get("default")) .setStatus(buildStatus(map.get("status"))) .setEntrySchema(buildEntrySchema(map.get("entry_schema"), new Parameter<TEntrySchema>(parameter.getContext()).addContext("entry_schema") )) .build(); }
@Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof TAttributeDefinition)) return false; TAttributeDefinition that = (TAttributeDefinition) o; return Objects.equals(getDescription(), that.getDescription()) && Objects.equals(getType(), that.getType()) && Objects.equals(getDefault(), that.getDefault()) && getStatus() == that.getStatus() && Objects.equals(getEntrySchema(), that.getEntrySchema()); }
public Printer visit(TAttributeDefinition node, Parameter parameter) { return new Printer(parameter.getIndent()) .printKeyValue("description", node.getDescription()) .printKeyValue("type", node.getType()) .printKeyObject("default", node.getDefault()) .printKeyValue("status", node.getStatus()) .print(printVisitorNode(node.getEntrySchema(), parameter)); }