Skip to content

Commit

Permalink
Update list reporter documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
LitschiW committed Jul 14, 2023
1 parent 9a6d991 commit 9b649f3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
24 changes: 21 additions & 3 deletions src/main/java/cambio/simulator/export/AsyncListReportWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,29 @@
import java.util.function.Function;

/**
* A {@link AsyncReportWriter} that writes a list of values to a single column.
* The list is formatted as a JSON array, but trimmed of the brackets.
* A {@link AsyncReportWriter} that writes a list of values to a single column. The list is formatted as a JSON array.
* The list/row is closed and a new one started when a new time is given.
*
* <p>
* Example:
* <table>
* <caption>AsyncListReportWriter Example</caption>
* <tr>
* <th>SimulationTime</th>
* <th>Value</th>
* </tr>
* <tr>
* <td>0.0</td>
* <td>[1,2,3]</td>
* </tr>
* <tr>
* <td>0.1</td>
* <td>[4,5,6]</td>
* </tr>
* </table>
*
* @author Lion Wagner
* @see AsyncReportWriter for more information
* @see AsyncReportWriter
*/
public class AsyncListReportWriter extends AsyncReportWriter<Object> {
//we use Object as generic type to move the "toString" conversion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,7 @@ public void addDataPoint(double time, byte[] data) {
@Override
public Function<Pair<Double, Iterable<?>>, String> createFormatter() {
return pair -> {
StringBuilder builder = new StringBuilder();
builder.append(pair.getValue0());
StringBuilder builder = new StringBuilder(String.valueOf(pair.getValue0()));
for (Object o : pair.getValue1()) {
builder.append(MiSimReporters.csvSeperator).append(o);
}
Expand Down

0 comments on commit 9b649f3

Please sign in to comment.