[LIB-10] SerialVersionUID for Serializable classes
[snooker-score-api.git] / src / main / java / org / hedgecode / snooker / json / JsonRankings.java
index 75a3358..d00a814 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.RankingComparators;
  *
  * @author Dmitry Samoshin aka gotty
  */
-public class JsonRankings extends JsonCollectionEntity<Ranking> implements Rankings {
+public class JsonRankings extends JsonCollectionEntity<Ranking> implements Rankings, Serializable {
 
-    protected JsonRankings(Ranking[] entities) {
+    private static final long serialVersionUID = -1765390719034378729L;
+
+    private static final JsonRankings EMPTY = new JsonRankings(new Ranking[0]);
+
+    JsonRankings(Ranking[] entities) {
         super(entities);
     }
 
-    protected JsonRankings(List<Ranking> entities) {
+    JsonRankings(List<Ranking> entities) {
         super(entities);
     }
 
@@ -52,7 +57,7 @@ public class JsonRankings extends JsonCollectionEntity<Ranking> implements Ranki
         for (Ranking ranking : this)
             if (ranking.sum() >= minSum && ranking.sum() <= maxSum)
                 rankings.add(ranking);
-        return rankings.isEmpty() ? null : new JsonRankings(rankings);
+        return rankings.isEmpty() ? EMPTY : new JsonRankings(rankings);
     }
 
     @Override
@@ -68,4 +73,5 @@ public class JsonRankings extends JsonCollectionEntity<Ranking> implements Ranki
                 RankingComparators.SUM.comparator()
         );
     }
+
 }