*/
public class Season implements Serializable {
+ private static final long serialVersionUID = -4233073149675278053L;
+
private static final Calendar CURRENT_CALENDAR = Calendar.getInstance();
private static final int NEW_SEASON_MONTH = 5; /* June */
*/
public class SnookerURL implements Serializable {
+ private static final long serialVersionUID = 5068013909126568563L;
+
private String name;
private URL url;
package org.hedgecode.snooker.compare;
-import java.io.Serializable;
import java.util.Comparator;
import org.hedgecode.snooker.api.Event;
return comparator;
}
- static class DateComparator implements Comparator<Event>, Serializable {
+ static class DateComparator implements Comparator<Event> {
@Override
public int compare(Event event1, Event event2) {
}
- static class SnookerIdComparator implements Comparator<Event>, Serializable {
+ static class SnookerIdComparator implements Comparator<Event> {
@Override
public int compare(Event event1, Event event2) {
package org.hedgecode.snooker.compare;
-import java.io.Serializable;
import java.util.Comparator;
import org.hedgecode.snooker.api.Match;
return comparator;
}
- static class RoundNumberComparator implements Comparator<Match>, Serializable {
+ static class RoundNumberComparator implements Comparator<Match> {
@Override
public int compare(Match match1, Match match2) {
}
- static class EventComparator implements Comparator<Match>, Serializable {
+ static class EventComparator implements Comparator<Match> {
@Override
public int compare(Match match1, Match match2) {
package org.hedgecode.snooker.compare;
-import java.io.Serializable;
import java.util.Comparator;
import org.hedgecode.snooker.api.Player;
return comparator;
}
- static class NameComparator implements Comparator<Player>, Serializable {
+ static class NameComparator implements Comparator<Player> {
@Override
public int compare(Player player1, Player player2) {
}
- static class AgeComparator implements Comparator<Player>, Serializable {
+ static class AgeComparator implements Comparator<Player> {
@Override
public int compare(Player player1, Player player2) {
package org.hedgecode.snooker.compare;
-import java.io.Serializable;
import java.util.Comparator;
import org.hedgecode.snooker.api.Ranking;
return comparator;
}
- static class PositionComparator implements Comparator<Ranking>, Serializable {
+ static class PositionComparator implements Comparator<Ranking> {
@Override
public int compare(Ranking ranking1, Ranking ranking2) {
}
- static class SumComparator implements Comparator<Ranking>, Serializable {
+ static class SumComparator implements Comparator<Ranking> {
@Override
public int compare(Ranking ranking1, Ranking ranking2) {
package org.hedgecode.snooker.compare;
-import java.io.Serializable;
import java.util.Comparator;
import org.hedgecode.snooker.api.Round;
return comparator;
}
- static class RoundComparator implements Comparator<Round>, Serializable {
+ static class RoundComparator implements Comparator<Round> {
@Override
public int compare(Round round1, Round round2) {
}
- static class EventComparator implements Comparator<Round>, Serializable {
+ static class EventComparator implements Comparator<Round> {
@Override
public int compare(Round round1, Round round2) {
package org.hedgecode.snooker.compare;
-import java.io.Serializable;
import java.util.Comparator;
import org.hedgecode.snooker.api.Seeding;
return comparator;
}
- static class EventComparator implements Comparator<Seeding>, Serializable {
+ static class EventComparator implements Comparator<Seeding> {
@Override
public int compare(Seeding seeding1, Seeding seeding2) {
}
- static class PlayerComparator implements Comparator<Seeding>, Serializable {
+ static class PlayerComparator implements Comparator<Seeding> {
@Override
public int compare(Seeding seeding1, Seeding seeding2) {
}
- static class SeedingComparator implements Comparator<Seeding>, Serializable {
+ static class SeedingComparator implements Comparator<Seeding> {
@Override
public int compare(Seeding seeding1, Seeding seeding2) {
public abstract class JsonCollectionEntity<E extends IdEntity>
implements CollectionEntity<E>, Serializable
{
+ private static final long serialVersionUID = 6302642716627217361L;
+
private final Map<Integer, E> entities = new LinkedHashMap<>();
- protected JsonCollectionEntity(E[] entities) {
+ JsonCollectionEntity(E[] entities) {
for (E entity : entities) {
if (entity != null)
this.entities.put(
}
}
- protected JsonCollectionEntity(List<E> entities) {
+ JsonCollectionEntity(List<E> entities) {
for (E entity : entities) {
this.entities.put(
entity.getId(), entity
package org.hedgecode.snooker.json;
+import java.io.Serializable;
import java.util.Date;
import com.google.gson.annotations.Expose;
*
* @author Dmitry Samoshin aka gotty
*/
-public class JsonEvent extends JsonIdEntity implements Event {
+public class JsonEvent extends JsonIdEntity implements Event, Serializable {
+
+ private static final long serialVersionUID = 3074418501643772690L;
@SerializedName("ID")
private int eventId;
@Expose
private Event previousEdition;
- protected JsonEvent() {
+ JsonEvent() {
}
@Override
package org.hedgecode.snooker.json;
+import java.io.Serializable;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
*
* @author Dmitry Samoshin aka gotty
*/
-public class JsonEvents extends JsonCollectionEntity<Event> implements Events {
+public class JsonEvents extends JsonCollectionEntity<Event> implements Events, Serializable {
+
+ private static final long serialVersionUID = 3333612126168481839L;
private static final JsonEvents EMPTY = new JsonEvents(new Event[0]);
- protected JsonEvents(Event[] entities) {
+ JsonEvents(Event[] entities) {
super(entities);
}
- protected JsonEvents(List<Event> entities) {
+ JsonEvents(List<Event> entities) {
super(entities);
}
package org.hedgecode.snooker.json;
-import java.io.Serializable;
-
import org.hedgecode.snooker.api.IdEntity;
/**
*
* @author Dmitry Samoshin aka gotty
*/
-public abstract class JsonIdEntity
- extends JsonURLEntity
- implements IdEntity, Serializable
-{
+public abstract class JsonIdEntity extends JsonURLEntity implements IdEntity {
+
@Override
public boolean equals(Object obj) {
if (this == obj)
@Override
public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + getId();
+ int result = getClass().getSimpleName().hashCode();
+ result = 31 * result + getId();
return result;
}
package org.hedgecode.snooker.json;
+import java.io.Serializable;
import java.util.Date;
import com.google.gson.annotations.Expose;
*
* @author Dmitry Samoshin aka gotty
*/
-public class JsonMatch extends JsonIdEntity implements Match {
+public class JsonMatch extends JsonIdEntity implements Match, Serializable {
+
+ private static final long serialVersionUID = 1503003854433798119L;
@SerializedName("ID")
private int matchId;
@SerializedName("ExtendedNote")
private String extendedNote;
- protected JsonMatch() {
+ JsonMatch() {
}
@Override
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 {
+
+ private static final long serialVersionUID = 7399435317464241002L;
private static final JsonMatches EMPTY = new JsonMatches(new Match[0]);
- protected JsonMatches(Match[] entities) {
+ JsonMatches(Match[] entities) {
super(entities);
}
- protected JsonMatches(List<Match> entities) {
+ JsonMatches(List<Match> entities) {
super(entities);
}
package org.hedgecode.snooker.json;
+import java.io.Serializable;
+
import org.hedgecode.snooker.api.OngoingMatch;
/**
*
* @author Dmitry Samoshin aka gotty
*/
-public class JsonOngoingMatch extends JsonMatch implements OngoingMatch {
+public class JsonOngoingMatch extends JsonMatch implements OngoingMatch, Serializable {
+
+ private static final long serialVersionUID = -6395358544537389727L;
- protected JsonOngoingMatch() {
+ JsonOngoingMatch() {
}
}
package org.hedgecode.snooker.json;
+import java.io.Serializable;
+
import org.hedgecode.snooker.api.OngoingMatch;
import org.hedgecode.snooker.api.OngoingMatches;
* @author Dmitry Samoshin aka gotty
*/
public class JsonOngoingMatches
- extends JsonCollectionEntity<OngoingMatch> implements OngoingMatches
+ extends JsonCollectionEntity<OngoingMatch>
+ implements OngoingMatches, Serializable
{
- protected JsonOngoingMatches(OngoingMatch[] entities) {
+ private static final long serialVersionUID = 1026260972671849624L;
+
+ JsonOngoingMatches(OngoingMatch[] entities) {
super(entities);
}
package org.hedgecode.snooker.json;
+import java.io.Serializable;
import java.net.URL;
import java.util.Date;
*
* @author Dmitry Samoshin aka gotty
*/
-public class JsonPlayer extends JsonIdEntity implements Player {
+public class JsonPlayer extends JsonIdEntity implements Player, Serializable {
+
+ private static final long serialVersionUID = 5978347071162091429L;
@SerializedName("ID")
private int playerId;
@SerializedName("Info")
private String info;
- protected JsonPlayer() {
+ JsonPlayer() {
}
@Override
package org.hedgecode.snooker.json;
+import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
*
* @author Dmitry Samoshin aka gotty
*/
-public class JsonPlayers extends JsonCollectionEntity<Player> implements Players {
+public class JsonPlayers extends JsonCollectionEntity<Player> implements Players, Serializable {
+
+ private static final long serialVersionUID = 7472642207778686468L;
private static final JsonPlayers EMPTY = new JsonPlayers(new Player[0]);
- protected JsonPlayers(Player[] entities) {
+ JsonPlayers(Player[] entities) {
super(entities);
}
- protected JsonPlayers(List<Player> entities) {
+ JsonPlayers(List<Player> entities) {
super(entities);
}
package org.hedgecode.snooker.json;
+import java.io.Serializable;
+
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
*
* @author Dmitry Samoshin aka gotty
*/
-public class JsonRanking extends JsonIdEntity implements Ranking {
+public class JsonRanking extends JsonIdEntity implements Ranking, Serializable {
+
+ private static final long serialVersionUID = -8009582917499815478L;
@SerializedName("ID")
private int rankingId;
@Expose
private RankingType rankingType;
- protected JsonRanking() {
+ JsonRanking() {
}
@Override
package org.hedgecode.snooker.json;
+import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
*
* @author Dmitry Samoshin aka gotty
*/
-public class JsonRankings extends JsonCollectionEntity<Ranking> implements Rankings {
+public class JsonRankings extends JsonCollectionEntity<Ranking> implements Rankings, Serializable {
+
+ private static final long serialVersionUID = -1765390719034378729L;
private static final JsonRankings EMPTY = new JsonRankings(new Ranking[0]);
- protected JsonRankings(Ranking[] entities) {
+ JsonRankings(Ranking[] entities) {
super(entities);
}
- protected JsonRankings(List<Ranking> entities) {
+ JsonRankings(List<Ranking> entities) {
super(entities);
}
package org.hedgecode.snooker.json;
+import java.io.Serializable;
+
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
*
* @author Dmitry Samoshin aka gotty
*/
-public class JsonRound extends JsonIdEntity implements Round {
+public class JsonRound extends JsonIdEntity implements Round, Serializable {
+
+ private static final long serialVersionUID = -2010008975829800984L;
@SerializedName("Round")
private int round;
@SerializedName("SeedPoints")
private int seedPoints;
- protected JsonRound() {
+ JsonRound() {
}
@Override
package org.hedgecode.snooker.json;
+import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
*
* @author Dmitry Samoshin aka gotty
*/
-public class JsonRounds extends JsonCollectionEntity<Round> implements Rounds {
+public class JsonRounds extends JsonCollectionEntity<Round> implements Rounds, Serializable {
+
+ private static final long serialVersionUID = -292582814222405882L;
private static final JsonRounds EMPTY = new JsonRounds(new Round[0]);
- protected JsonRounds(Round[] entities) {
+ JsonRounds(Round[] entities) {
super(entities);
}
- protected JsonRounds(List<Round> entities) {
+ JsonRounds(List<Round> entities) {
super(entities);
}
package org.hedgecode.snooker.json;
+import java.io.Serializable;
+
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
*
* @author Dmitry Samoshin aka gotty
*/
-public class JsonSeeding extends JsonIdEntity implements Seeding {
+public class JsonSeeding extends JsonIdEntity implements Seeding, Serializable {
+
+ private static final long serialVersionUID = -9182126924854384725L;
@SerializedName("EventID")
private int eventId;
@SerializedName("Seeding")
private int seeding;
- protected JsonSeeding() {
+ JsonSeeding() {
}
@Override
package org.hedgecode.snooker.json;
+import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
*
* @author Dmitry Samoshin aka gotty
*/
-public class JsonSeedings extends JsonCollectionEntity<Seeding> implements Seedings {
+public class JsonSeedings extends JsonCollectionEntity<Seeding> implements Seedings, Serializable {
+
+ private static final long serialVersionUID = 8251290277292098461L;
private static final JsonSeedings EMPTY = new JsonSeedings(new Seeding[0]);
- protected JsonSeedings(Seeding[] entities) {
+ JsonSeedings(Seeding[] entities) {
super(entities);
}
- protected JsonSeedings(List<Seeding> entities) {
+ JsonSeedings(List<Seeding> entities) {
super(entities);
}
return sb.toString();
}
+ protected void verifySerialize(Serializable serializeObject) throws IOException {
+ if (!serializeFile.exists()) {
+ serialize(serializeObject);
+ }
+ }
+
protected void serialize(Serializable serializeObject) throws IOException {
try (ObjectOutputStream oos =
new ObjectOutputStream(
),
JsonEvent[].class
);
- //serialize(jsonEvents[0]);
+ verifySerialize(jsonEvents[0]);
JsonEvent expectedEvent = (JsonEvent) deserialize();
assertNull(
expectedEvent,
JsonEvent[].class
)
);
- //serialize(actualEvents);
+ verifySerialize(actualEvents);
JsonEvents expectedEvents = (JsonEvents) deserialize();
assertEquals(
expectedEvents,
),
JsonMatch[].class
);
- //serialize(jsonMatches[0]);
+ verifySerialize(jsonMatches[0]);
JsonMatch expectedMatch = (JsonMatch) deserialize();
assertNull(
expectedMatch,
JsonMatch[].class
)
);
- //serialize(actualMatches);
+ verifySerialize(actualMatches);
JsonMatches expectedMatches = (JsonMatches) deserialize();
assertEquals(
expectedMatches,
),
JsonOngoingMatch[].class
);
- //serialize(jsonOngoingMatches[0]);
+ verifySerialize(jsonOngoingMatches[0]);
JsonOngoingMatch expectedOngoingMatch = (JsonOngoingMatch) deserialize();
assertNull(
expectedOngoingMatch,
JsonOngoingMatch[].class
)
);
- //serialize(actualOngoingMatches);
+ verifySerialize(actualOngoingMatches);
JsonOngoingMatches expectedOngoingMatches = (JsonOngoingMatches) deserialize();
assertEquals(
expectedOngoingMatches,
),
JsonPlayer[].class
);
- //serialize(jsonPlayers[0]);
+ verifySerialize(jsonPlayers[0]);
JsonPlayer expectedPlayer = (JsonPlayer) deserialize();
assertNull(
expectedPlayer,
JsonPlayer[].class
)
);
- //serialize(actualPlayers);
+ verifySerialize(actualPlayers);
JsonPlayers expectedPlayers = (JsonPlayers) deserialize();
assertEquals(
expectedPlayers,
),
JsonRanking[].class
);
- //serialize(jsonRankings[0]);
+ verifySerialize(jsonRankings[0]);
JsonRanking expectedRanking = (JsonRanking) deserialize();
assertNull(
expectedRanking,
JsonRanking[].class
)
);
- //serialize(actualRankings);
+ verifySerialize(actualRankings);
JsonRankings expectedRankings = (JsonRankings) deserialize();
assertEquals(
expectedRankings,
),
JsonRound[].class
);
- //serialize(jsonRounds[0]);
+ verifySerialize(jsonRounds[0]);
JsonRound expectedRound = (JsonRound) deserialize();
assertNull(
expectedRound,
JsonRound[].class
)
);
- //serialize(actualRounds);
+ verifySerialize(actualRounds);
JsonRounds expectedRounds = (JsonRounds) deserialize();
assertEquals(
expectedRounds,
),
JsonSeeding[].class
);
- //serialize(jsonSeedings[0]);
+ verifySerialize(jsonSeedings[0]);
JsonSeeding expectedSeeding = (JsonSeeding) deserialize();
assertNull(
expectedSeeding,
JsonSeeding[].class
)
);
- //serialize(actualSeedings);
+ verifySerialize(actualSeedings);
JsonSeedings expectedSeedings = (JsonSeedings) deserialize();
assertEquals(
expectedSeedings,