1313
1414public class ResultSetImpl implements ResultSet {
1515
16- private Header header = new HeaderImpl (new ArrayList <>());
17- private Statistics statistics = new StatisticsImpl (new ArrayList <>());
18-
19- private final List <Record > results = new ArrayList <>();
16+ private final Header header ;
17+ private final Statistics statistics ;
18+ private final List <Record > results ;
2019
2120 private int position = 0 ;
2221 private final GraphCache graphCache ;
@@ -30,23 +29,28 @@ public ResultSetImpl(List<Object> rawResponse, GraphCache graphCache) {
3029 this .graphCache = graphCache ;
3130 if (rawResponse .size () != 3 ) {
3231
33- parseStatistics (rawResponse .get (rawResponse .size () - 1 ));
32+ header = parseHeader (new ArrayList <>());
33+ results = new ArrayList <>();
34+ statistics = parseStatistics (rawResponse .get (rawResponse .size () - 1 ));
3435
3536 } else {
3637
37- parseHeader ((List <List <Object >>) rawResponse .get (0 ));
38- parseResult ((List <List <Object >>) rawResponse .get (1 ));
39- parseStatistics ((List <Object >) rawResponse .get (2 ));
38+ header = parseHeader ((List <List <Object >>) rawResponse .get (0 ));
39+ results = parseResult ((List <List <Object >>) rawResponse .get (1 ));
40+ statistics = parseStatistics ((List <Object >) rawResponse .get (2 ));
4041 }
4142 }
4243
4344
4445 /**
46+ *
4547 * @param rawResultSet - raw result set representation
48+ * @return parsed result set
4649 */
47- private void parseResult (List <List <Object >> rawResultSet ) {
50+ private List <Record > parseResult (List <List <Object >> rawResultSet ) {
51+ List <Record > results = new ArrayList <>();
4852 if (rawResultSet == null || rawResultSet .isEmpty ()) {
49- return ;
53+ return results ;
5054 } else {
5155 //go over each raw result
5256 for (List <Object > row : rawResultSet ) {
@@ -78,21 +82,26 @@ private void parseResult(List<List<Object>> rawResultSet) {
7882 results .add (record );
7983 }
8084 }
85+ return results ;
8186 }
8287
8388 /**
89+ *
8490 * @param rawStatistics raw statistics representation
91+ * @return parsed statistics
8592 */
86- private void parseStatistics (Object rawStatistics ) {
87- statistics = new StatisticsImpl ((List <byte []>) rawStatistics );
93+ private StatisticsImpl parseStatistics (Object rawStatistics ) {
94+ return new StatisticsImpl ((List <byte []>) rawStatistics );
8895 }
8996
9097
9198 /**
92- * @param rawHeader raw header representation
99+ *
100+ * @param rawHeader - raw header representation
101+ * @return parsed header
93102 */
94- private void parseHeader (List <List <Object >> rawHeader ) {
95- header = new HeaderImpl (rawHeader );
103+ private HeaderImpl parseHeader (List <List <Object >> rawHeader ) {
104+ return new HeaderImpl (rawHeader );
96105 }
97106
98107 @ Override
0 commit comments