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.annotation.IsURL;
25 import org.hedgecode.snooker.annotation.WithHTMLTags;
26 import org.hedgecode.snooker.api.Event;
27 import org.hedgecode.snooker.api.Match;
28 import org.hedgecode.snooker.api.Player;
31 * Match Entity to JSON deserialize.
33 * @author Dmitry Samoshin aka gotty
35 public class JsonMatch extends JsonIdEntity implements Match {
39 @SerializedName("EventID")
43 @SerializedName("Round")
45 @SerializedName("Number")
47 @SerializedName("Player1ID")
48 private int player1Id;
50 private Player player1;
51 @SerializedName("Score1")
53 @SerializedName("Walkover1")
54 private boolean walkover1;
55 @SerializedName("Player2ID")
56 private int player2Id;
58 private Player player2;
59 @SerializedName("Score2")
61 @SerializedName("Walkover2")
62 private boolean walkover2;
63 @SerializedName("WinnerID")
66 private Player winner;
67 @SerializedName("Unfinished")
68 private boolean unfinished;
69 @SerializedName("OnBreak")
70 private boolean onBreak;
71 @SerializedName("WorldSnookerID")
72 private int worldSnookerId;
74 @SerializedName("LiveUrl")
75 private String liveUrl;
77 @SerializedName("DetailsUrl")
78 private String detailsUrl;
79 @SerializedName("PointsDropped")
80 private boolean pointsDropped;
81 @SerializedName("ShowCommonNote")
82 private boolean showCommonNote;
83 @SerializedName("Estimated")
84 private boolean estimated;
85 @SerializedName("Type")
87 @SerializedName("TableNo")
90 @SerializedName("VideoURL")
91 private String videoUrl;
92 @SerializedName("InitDate")
93 private Date initDate;
94 @SerializedName("ModDate")
96 @SerializedName("StartDate")
97 private Date startDate;
98 @SerializedName("EndDate")
100 @SerializedName("ScheduledDate")
101 private Date scheduledDate;
103 @SerializedName("FrameScores")
104 private String frameScores;
106 @SerializedName("Sessions")
107 private String sessions;
109 @SerializedName("Note")
112 @SerializedName("ExtendedNote")
113 private String extendedNote;
115 protected JsonMatch() {
119 public int matchId() {
124 public int eventId() {
129 public Event event() {
133 public void setEvent(Event event) {
134 if (event != null && eventId == event.eventId())
144 public int number() {
149 public int player1Id() {
154 public Player player1() {
158 public void setPlayer1(Player player) {
159 if (player != null && player1Id == player.playerId())
160 this.player1 = player;
164 public int score1() {
169 public boolean walkover1() {
174 public int player2Id() {
179 public Player player2() {
183 public void setPlayer2(Player player) {
184 if (player != null && player2Id == player.playerId())
185 this.player2 = player;
189 public int score2() {
194 public boolean walkover2() {
199 public int winnerId() {
204 public Player winner() {
208 public void setWinner(Player winner) {
209 if (winner != null && winnerId == winner.playerId())
210 this.winner = winner;
214 public boolean unfinished() {
219 public boolean onBreak() {
224 public int worldSnookerId() {
225 return worldSnookerId;
229 public String liveUrl() {
234 public String detailsUrl() {
239 public boolean pointsDropped() {
240 return pointsDropped;
244 public boolean showCommonNote() {
245 return showCommonNote;
249 public boolean estimated() {
259 public int tableNo() {
264 public String videoUrl() {
269 public Date initDate() {
270 return initDate == null
272 : new Date(initDate.getTime());
276 public Date modDate() {
277 return modDate == null
279 : new Date(modDate.getTime());
283 public Date startDate() {
284 return startDate == null
286 : new Date(startDate.getTime());
290 public Date endDate() {
291 return endDate == null
293 : new Date(endDate.getTime());
297 public Date scheduledDate() {
298 return scheduledDate == null
300 : new Date(scheduledDate.getTime());
304 public String frameScores() {
309 public String sessions() {
314 public String note() {
319 public String extendedNote() {