/* * Copyright (c) 2017. 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. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.hedgecode.snooker.json; import java.util.Date; import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; import org.hedgecode.snooker.api.Event; import org.hedgecode.snooker.api.Match; import org.hedgecode.snooker.api.Player; /** * Match Entity to JSON deserialize. * * @author Dmitry Samoshin aka gotty */ public class JsonMatch extends JsonIdEntity implements Match { @SerializedName("ID") private int matchId; @SerializedName("EventID") private int eventId; @Expose private Event event; @SerializedName("Round") private int round; @SerializedName("Number") private int number; @SerializedName("Player1ID") private int player1Id; @Expose private Player player1; @SerializedName("Score1") private int score1; @SerializedName("Walkover1") private boolean walkover1; @SerializedName("Player2ID") private int player2Id; @Expose private Player player2; @SerializedName("Score2") private int score2; @SerializedName("Walkover2") private boolean walkover2; @SerializedName("WinnerID") private int winnerId; @Expose private Player winner; @SerializedName("Unfinished") private boolean unfinished; @SerializedName("OnBreak") private boolean onBreak; @SerializedName("WorldSnookerID") private int worldSnookerId; @SerializedName("LiveUrl") private String liveUrl; @SerializedName("DetailsUrl") private String detailsUrl; @SerializedName("PointsDropped") private boolean pointsDropped; @SerializedName("ShowCommonNote") private boolean showCommonNote; @SerializedName("Estimated") private boolean estimated; @SerializedName("Type") private int type; @SerializedName("TableNo") private int tableNo; @SerializedName("VideoURL") private String videoURL; @SerializedName("InitDate") private Date initDate; @SerializedName("ModDate") private Date modDate; @SerializedName("StartDate") private Date startDate; @SerializedName("EndDate") private Date endDate; @SerializedName("ScheduledDate") private Date scheduledDate; @SerializedName("FrameScores") private String frameScores; @SerializedName("Sessions") private String sessions; @SerializedName("Note") private String note; @SerializedName("ExtendedNote") private String extendedNote; protected JsonMatch() { } @Override public int matchId() { return matchId; } @Override public int eventId() { return eventId; } @Override public Event event() { return event; } public void setEvent(Event event) { if (event != null && eventId == event.eventId()) this.event = event; } @Override public int round() { return round; } @Override public int number() { return number; } @Override public int player1Id() { return player1Id; } @Override public Player player1() { return player1; } public void setPlayer1(Player player) { if (player != null && player1Id == player.playerId()) this.player1 = player; } @Override public int score1() { return score1; } @Override public boolean walkover1() { return walkover1; } @Override public int player2Id() { return player2Id; } @Override public Player player2() { return player2; } public void setPlayer2(Player player) { if (player != null && player2Id == player.playerId()) this.player2 = player; } @Override public int score2() { return score2; } @Override public boolean walkover2() { return walkover2; } @Override public int winnerId() { return winnerId; } @Override public Player winner() { return winner; } public void setWinner(Player winner) { if (winner != null && winnerId == winner.playerId()) this.winner = winner; } @Override public boolean unfinished() { return unfinished; } @Override public boolean onBreak() { return onBreak; } @Override public int worldSnookerId() { return worldSnookerId; } @Override public String liveUrl() { return liveUrl; } @Override public String detailsUrl() { return detailsUrl; } @Override public boolean pointsDropped() { return pointsDropped; } @Override public boolean showCommonNote() { return showCommonNote; } @Override public boolean estimated() { return estimated; } @Override public int type() { return type; } @Override public int tableNo() { return tableNo; } @Override public String videoURL() { return videoURL; } @Override public Date initDate() { return initDate == null ? null : new Date(initDate.getTime()); } @Override public Date modDate() { return modDate == null ? null : new Date(modDate.getTime()); } @Override public Date startDate() { return startDate == null ? null : new Date(startDate.getTime()); } @Override public Date endDate() { return endDate == null ? null : new Date(endDate.getTime()); } @Override public Date scheduledDate() { return scheduledDate == null ? null : new Date(scheduledDate.getTime()); } @Override public String frameScores() { return frameScores; } @Override public String sessions() { return sessions; } @Override public String note() { return note; } @Override public String extendedNote() { return extendedNote; } @Override public int getId() { return matchId; } }