/** * Called by subclasses to add the fields common to all subclasses to JSON serializations. * * @param root a JsonObject instance representing a serialization of this object. */ protected void addCommonFields(JsonObject root) { root.addProperty("fieldName", this.fieldName); root.addProperty("owner", Util.join(".", this.dataModelObject.getField(fieldName).getOwnerLineage())); root.addProperty("type", this.getType().toString()); } }
/** * @return a JSON serialization of this object. */ JsonObject toJson() { JsonObject root = new JsonObject(); root.addProperty("dataModel", this.dataModelObject.getDataModel().getName()); root.addProperty("baseClass", this.dataModelObject.getName()); JsonArray filterArray = new JsonArray(); for (PivotFilter p : filters) { filterArray.add(p.toJson()); } root.add("filters", filterArray); JsonArray rowsplitArray = new JsonArray(); for (PivotRowSplit p : rows) { rowsplitArray.add(p.toJson()); } root.add("rows", rowsplitArray); JsonArray cellvalueArray = new JsonArray(); for (PivotCellValue p : cells) { cellvalueArray.add(p.toJson()); } root.add("cells", cellvalueArray); JsonArray columnsplitArray = new JsonArray(); for (PivotColumnSplit p : columns) { columnsplitArray.add(p.toJson()); } root.add("columns", columnsplitArray); return root; }