1 package de.aikiit.bilanzanalyser.reader;
2
3 import de.aikiit.bilanzanalyser.entity.BilanzRow;
4
5 import java.util.List;
6
7
8
9
10
11
12
13
14 public record BilanzRowParserResult(int errorCount, int rowCount, List<BilanzRow> rows) {
15
16 public BilanzRowParserResult {
17 rows = rows == null ? List.of() : List.copyOf(rows);
18 }
19
20 public static BilanzRowParserResult empty() {
21 return new BilanzRowParserResult(0, 0, List.of());
22 }
23
24
25
26
27
28
29 public boolean isEmpty() {
30 return rows == null || rows.isEmpty() || errorCount == 0;
31 }
32
33
34
35
36
37
38 public BilanzRowParserResult withError() {
39 return new BilanzRowParserResult(errorCount + 1, rowCount, rows);
40 }
41
42
43
44
45
46
47 public BilanzRowParserResult withRow() {
48 return new BilanzRowParserResult(errorCount, rowCount + 1, rows);
49 }
50
51
52
53
54
55
56
57 public BilanzRowParserResult withRows(List<BilanzRow> newRows) {
58 return new BilanzRowParserResult(errorCount, rowCount, newRows);
59 }
60
61
62
63
64
65
66
67 public BilanzRowParserResult addRow(BilanzRow row) {
68 var newList = new java.util.ArrayList<>(rows);
69 newList.add(row);
70 return new BilanzRowParserResult(errorCount, rowCount, newList);
71 }
72 }