/*
- * Copyright (c) 2017. Developed by Hedgecode.
+ * Copyright (c) 2017-2020. Developed by Hedgecode.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.hedgecode.snooker.json;
+import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
*
* @author Dmitry Samoshin aka gotty
*/
-public class JsonMatches extends JsonCollectionEntity<Match> implements Matches {
+public class JsonMatches extends JsonCollectionEntity<Match> implements Matches, Serializable {
- protected JsonMatches(Match[] entities) {
+ private static final long serialVersionUID = 7399435317464241002L;
+
+ private static final JsonMatches EMPTY = new JsonMatches(new Match[0]);
+
+ JsonMatches(Match[] entities) {
super(entities);
}
- protected JsonMatches(List<Match> entities) {
+ JsonMatches(List<Match> entities) {
super(entities);
}
for (Match match : this)
if (match.eventId() == eventId)
matches.add(match);
- return matches.isEmpty() ? null : new JsonMatches(matches);
+ return matches.isEmpty() ? EMPTY : new JsonMatches(matches);
}
@Override
for (Match match : this)
if (match.eventId() == eventId && match.round() == round)
matches.add(match);
- return matches.isEmpty() ? null : new JsonMatches(matches);
+ return matches.isEmpty() ? EMPTY : new JsonMatches(matches);
}
@Override
for (Match match : this)
if (match.player1Id() == playerId || match.player2Id() == playerId)
matches.add(match);
- return matches.isEmpty() ? null : new JsonMatches(matches);
+ return matches.isEmpty() ? EMPTY : new JsonMatches(matches);
}
@Override
for (Match match : this)
if (match.endDate() != null)
matches.add(match);
- return matches.isEmpty() ? null : new JsonMatches(matches);
+ return matches.isEmpty() ? EMPTY : new JsonMatches(matches);
}
@Override
for (Match match : this)
if (match.startDate() != null && match.endDate() == null)
matches.add(match);
- return matches.isEmpty() ? null : new JsonMatches(matches);
+ return matches.isEmpty() ? EMPTY : new JsonMatches(matches);
}
@Override
for (Match match : this)
if (match.startDate() == null)
matches.add(match);
- return matches.isEmpty() ? null : new JsonMatches(matches);
+ return matches.isEmpty() ? EMPTY : new JsonMatches(matches);
}
@Override