2 * Copyright (c) 2017. Developed by Hedgecode.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.hedgecode.snooker.json;
19 import java.util.Date;
21 import com.google.gson.annotations.Expose;
22 import com.google.gson.annotations.SerializedName;
24 import org.hedgecode.snooker.api.Event;
25 import org.hedgecode.snooker.api.Match;
26 import org.hedgecode.snooker.api.Player;
29 * Match Entity to JSON deserialize.
31 * @author Dmitry Samoshin aka gotty
33 public class JsonMatch extends JsonIdEntity implements Match {
37 @SerializedName("EventID")
41 @SerializedName("Round")
43 @SerializedName("Number")
45 @SerializedName("Player1ID")
46 private int player1Id;
48 private Player player1;
49 @SerializedName("Score1")
51 @SerializedName("Walkover1")
52 private boolean walkover1;
53 @SerializedName("Player2ID")
54 private int player2Id;
56 private Player player2;
57 @SerializedName("Score2")
59 @SerializedName("Walkover2")
60 private boolean walkover2;
61 @SerializedName("WinnerID")
64 private Player winner;
65 @SerializedName("Unfinished")
66 private boolean unfinished;
67 @SerializedName("OnBreak")
68 private boolean onBreak;
69 @SerializedName("WorldSnookerID")
70 private int worldSnookerId;
71 @SerializedName("LiveUrl")
72 private String liveUrl;
73 @SerializedName("DetailsUrl")
74 private String detailsUrl;
75 @SerializedName("PointsDropped")
76 private boolean pointsDropped;
77 @SerializedName("ShowCommonNote")
78 private boolean showCommonNote;
79 @SerializedName("Estimated")
80 private boolean estimated;
81 @SerializedName("Type")
83 @SerializedName("TableNo")
85 @SerializedName("VideoURL")
86 private String videoURL;
87 @SerializedName("InitDate")
88 private Date initDate;
89 @SerializedName("ModDate")
91 @SerializedName("StartDate")
92 private Date startDate;
93 @SerializedName("EndDate")
95 @SerializedName("ScheduledDate")
96 private Date scheduledDate;
97 @SerializedName("FrameScores")
98 private String frameScores;
99 @SerializedName("Sessions")
100 private String sessions;
101 @SerializedName("Note")
103 @SerializedName("ExtendedNote")
104 private String extendedNote;
106 protected JsonMatch() {
110 public int matchId() {
115 public int eventId() {
120 public Event event() {
124 public void setEvent(Event event) {
125 if (event != null && eventId == event.eventId())
135 public int number() {
140 public int player1Id() {
145 public Player player1() {
149 public void setPlayer1(Player player) {
150 if (player != null && player1Id == player.playerId())
151 this.player1 = player;
155 public int score1() {
160 public boolean walkover1() {
165 public int player2Id() {
170 public Player player2() {
174 public void setPlayer2(Player player) {
175 if (player != null && player2Id == player.playerId())
176 this.player2 = player;
180 public int score2() {
185 public boolean walkover2() {
190 public int winnerId() {
195 public Player winner() {
199 public void setWinner(Player winner) {
200 if (winner != null && winnerId == winner.playerId())
201 this.winner = winner;
205 public boolean unfinished() {
210 public boolean onBreak() {
215 public int worldSnookerId() {
216 return worldSnookerId;
220 public String liveUrl() {
225 public String detailsUrl() {
230 public boolean pointsDropped() {
231 return pointsDropped;
235 public boolean showCommonNote() {
236 return showCommonNote;
240 public boolean estimated() {
250 public int tableNo() {
255 public String videoURL() {
260 public Date initDate() {
261 return initDate == null
263 : new Date(initDate.getTime());
267 public Date modDate() {
268 return modDate == null
270 : new Date(modDate.getTime());
274 public Date startDate() {
275 return startDate == null
277 : new Date(startDate.getTime());
281 public Date endDate() {
282 return endDate == null
284 : new Date(endDate.getTime());
288 public Date scheduledDate() {
289 return scheduledDate == null
291 : new Date(scheduledDate.getTime());
295 public String frameScores() {
300 public String sessions() {
305 public String note() {
310 public String extendedNote() {