X-Git-Url: https://git.hedgecode.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fmain%2Fjava%2Forg%2Fhedgecode%2Fsnooker%2Fjson%2FJsonMatches.java;h=83a02857e61c59bf2bc47ee277bf4b06c308200b;hb=edb206228987f506c5dc7a20585537b71f7a2e9d;hp=0d4dd0279a6d35b92cb1d90fdd47c3e5e89e0de5;hpb=20a8093246c9bb7def0c07a03bceff6f31412f35;p=snooker-score-api.git diff --git a/src/main/java/org/hedgecode/snooker/json/JsonMatches.java b/src/main/java/org/hedgecode/snooker/json/JsonMatches.java index 0d4dd02..83a0285 100644 --- a/src/main/java/org/hedgecode/snooker/json/JsonMatches.java +++ b/src/main/java/org/hedgecode/snooker/json/JsonMatches.java @@ -30,6 +30,8 @@ import org.hedgecode.snooker.compare.MatchComparators; */ public class JsonMatches extends JsonCollectionEntity implements Matches { + private static final JsonMatches EMPTY = new JsonMatches(new Match[0]); + protected JsonMatches(Match[] entities) { super(entities); } @@ -44,7 +46,7 @@ public class JsonMatches extends JsonCollectionEntity implements Matches 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 @@ -53,7 +55,7 @@ public class JsonMatches extends JsonCollectionEntity implements Matches 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 @@ -62,7 +64,7 @@ public class JsonMatches extends JsonCollectionEntity implements Matches 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 @@ -71,7 +73,7 @@ public class JsonMatches extends JsonCollectionEntity implements Matches 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 @@ -80,7 +82,7 @@ public class JsonMatches extends JsonCollectionEntity implements Matches 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 @@ -89,7 +91,7 @@ public class JsonMatches extends JsonCollectionEntity implements Matches 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