git.hedgecode.org
/
snooker-score-api.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
[LIB-5] Collection empty objects,reporting and serializable
[snooker-score-api.git]
/
src
/
main
/
java
/
org
/
hedgecode
/
snooker
/
json
/
JsonMatches.java
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
(file)
--- 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<Match> implements Matches {
*/
public class JsonMatches extends JsonCollectionEntity<Match> implements Matches {
+ private static final JsonMatches EMPTY = new JsonMatches(new Match[0]);
+
protected JsonMatches(Match[] entities) {
super(entities);
}
protected JsonMatches(Match[] entities) {
super(entities);
}
@@
-44,7
+46,7
@@
public class JsonMatches extends JsonCollectionEntity<Match> implements Matches
for (Match match : this)
if (match.eventId() == eventId)
matches.add(match);
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
}
@Override
@@
-53,7
+55,7
@@
public class JsonMatches extends JsonCollectionEntity<Match> implements Matches
for (Match match : this)
if (match.eventId() == eventId && match.round() == round)
matches.add(match);
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
}
@Override
@@
-62,7
+64,7
@@
public class JsonMatches extends JsonCollectionEntity<Match> implements Matches
for (Match match : this)
if (match.player1Id() == playerId || match.player2Id() == playerId)
matches.add(match);
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
}
@Override
@@
-71,7
+73,7
@@
public class JsonMatches extends JsonCollectionEntity<Match> implements Matches
for (Match match : this)
if (match.endDate() != null)
matches.add(match);
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
}
@Override
@@
-80,7
+82,7
@@
public class JsonMatches extends JsonCollectionEntity<Match> implements Matches
for (Match match : this)
if (match.startDate() != null && match.endDate() == null)
matches.add(match);
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
}
@Override
@@
-89,7
+91,7
@@
public class JsonMatches extends JsonCollectionEntity<Match> implements Matches
for (Match match : this)
if (match.startDate() == null)
matches.add(match);
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
}
@Override