[LIB-10] SerialVersionUID for Serializable classes
[snooker-score-api.git] / src / main / java / org / hedgecode / snooker / json / JsonMatches.java
index 0d4dd02..70698da 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * 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.
@@ -16,6 +16,7 @@
 
 package org.hedgecode.snooker.json;
 
+import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -28,13 +29,17 @@ import org.hedgecode.snooker.compare.MatchComparators;
  *
  * @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);
     }
 
@@ -44,7 +49,7 @@ public class JsonMatches extends JsonCollectionEntity<Match> 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 +58,7 @@ public class JsonMatches extends JsonCollectionEntity<Match> 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 +67,7 @@ public class JsonMatches extends JsonCollectionEntity<Match> 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 +76,7 @@ public class JsonMatches extends JsonCollectionEntity<Match> 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 +85,7 @@ public class JsonMatches extends JsonCollectionEntity<Match> 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 +94,7 @@ public class JsonMatches extends JsonCollectionEntity<Match> 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