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.EventFormat;
26 import org.hedgecode.snooker.api.Season;
29 * Event Entity to JSON deserialize.
31 * @author Dmitry Samoshin aka gotty
33 public class JsonEvent extends JsonIdEntity implements Event {
37 @SerializedName("Name")
39 @SerializedName("StartDate")
40 private Date startDate;
41 @SerializedName("EndDate")
43 @SerializedName("Sponsor")
44 private String sponsor;
45 @SerializedName("Season")
46 private int seasonYear;
48 private Season season;
49 @SerializedName("Type")
51 @SerializedName("Num")
53 @SerializedName("Venue")
55 @SerializedName("City")
57 @SerializedName("Country")
58 private String country;
59 @SerializedName("Discipline")
60 private String discipline;
61 @SerializedName("Main")
62 private int mainEventId;
64 private Event mainEvent;
65 @SerializedName("Sex")
67 @SerializedName("AgeGroup")
68 private String ageGroup;
69 @SerializedName("Url")
71 @SerializedName("Related")
72 private String related;
73 @SerializedName("Stage")
75 @SerializedName("ValueType")
76 private String valueType;
77 @SerializedName("ShortName")
78 private String shortName;
79 @SerializedName("WorldSnookerId")
80 private int worldSnookerId;
81 @SerializedName("RankingType")
82 private String rankingType;
83 @SerializedName("EventPredictionID")
84 private int eventPredictionId;
85 @SerializedName("Team")
87 @SerializedName("Format")
90 private EventFormat formatType;
91 @SerializedName("Twitter")
92 private String twitter;
93 @SerializedName("HashTag")
94 private String hashTag;
95 @SerializedName("ConversionRate")
96 private float conversionRate;
97 @SerializedName("AllRoundsAdded")
98 private boolean allRoundsAdded;
99 @SerializedName("PhotoURLs")
100 private String photoUrls;
101 @SerializedName("NumCompetitors")
102 private int numCompetitors;
103 @SerializedName("NumUpcoming")
104 private int numUpcoming;
105 @SerializedName("NumActive")
106 private int numActive;
107 @SerializedName("NumResults")
108 private int numResults;
109 @SerializedName("Note")
111 @SerializedName("CommonNote")
112 private String commonNote;
113 @SerializedName("DefendingChampion")
114 private int defendingChampion;
115 @SerializedName("PreviousEdition")
116 private int previousEdition;
118 protected JsonEvent() {
122 public int eventId() {
127 public String name() {
132 public Date startDate() {
133 return startDate == null
135 : new Date(startDate.getTime());
139 public Date endDate() {
140 return endDate == null
142 : new Date(endDate.getTime());
146 public String sponsor() {
151 public Season season() {
153 season = Season.getSeason(seasonYear);
158 public String type() {
168 public String venue() {
173 public String city() {
178 public String country() {
183 public String discipline() {
188 public int mainEventId() {
193 public Event mainEvent() {
194 if (mainEvent == null && mainEventId == eventId)
199 public void setMainEvent(Event event) {
200 if (event != null && eventId == event.eventId())
205 public String sex() {
210 public String ageGroup() {
215 public String url() {
220 public String related() {
225 public String stage() {
230 public String valueType() {
235 public String shortName() {
240 public int worldSnookerId() {
241 return worldSnookerId;
245 public String rankingType() {
250 public int eventPredictionId() {
251 return eventPredictionId;
255 public boolean team() {
260 public int format() {
265 public EventFormat formatType() {
266 if (formatType == null)
267 formatType = EventFormat.byNumber(format);
272 public String twitter() {
277 public String hashTag() {
282 public float conversionRate() {
283 return conversionRate;
287 public boolean allRoundsAdded() {
288 return allRoundsAdded;
292 public String photoUrls() {
297 public int numCompetitors() {
298 return numCompetitors;
302 public int numUpcoming() {
307 public int numActive() {
312 public int numResults() {
317 public String note() {
322 public String commonNote() {
327 public int defendingChampion() {
328 return defendingChampion;
332 public int previousEdition() {
333 return previousEdition;