[LIB-2] Add snooker-score-api source files
[snooker-score-api.git] / src / main / java / org / hedgecode / snooker / json / JsonEvent.java
1 /*
2  * Copyright (c) 2017. Developed by Hedgecode.
3  *
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
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 package org.hedgecode.snooker.json;
18
19 import java.util.Date;
20
21 import com.google.gson.annotations.Expose;
22 import com.google.gson.annotations.SerializedName;
23
24 import org.hedgecode.snooker.api.Event;
25 import org.hedgecode.snooker.api.Season;
26
27 /**
28  * Event Entity to JSON deserialize.
29  *
30  * @author Dmitry Samoshin aka gotty
31  */
32 public class JsonEvent extends JsonIdEntity implements Event {
33
34     @SerializedName("ID")
35     private int eventId;
36     @SerializedName("Name")
37     private String name;
38     @SerializedName("StartDate")
39     private Date startDate;
40     @SerializedName("EndDate")
41     private Date endDate;
42     @SerializedName("Sponsor")
43     private String sponsor;
44     @SerializedName("Season")
45     private int seasonYear;
46     @Expose
47     private Season season;
48     @SerializedName("Type")
49     private String type;
50     @SerializedName("Num")
51     private int num;
52     @SerializedName("Venue")
53     private String venue;
54     @SerializedName("City")
55     private String city;
56     @SerializedName("Country")
57     private String country;
58     @SerializedName("Discipline")
59     private String discipline;
60     @SerializedName("Main")
61     private int mainEventId;
62     @Expose
63     private Event mainEvent;
64     @SerializedName("Sex")
65     private String sex;
66     @SerializedName("AgeGroup")
67     private String ageGroup;
68     @SerializedName("Url")
69     private String url;
70     @SerializedName("Related")
71     private String related;
72     @SerializedName("Stage")
73     private String stage;
74     @SerializedName("ValueType")
75     private String valueType;
76     @SerializedName("ShortName")
77     private String shortName;
78     @SerializedName("WorldSnookerId")
79     private int worldSnookerId;
80     @SerializedName("RankingType")
81     private String rankingType;
82     @SerializedName("EventPredictionID")
83     private int eventPredictionId;
84     @SerializedName("Team")
85     private boolean team;
86     @SerializedName("Format")
87     private int format;
88     @SerializedName("Twitter")
89     private String twitter;
90     @SerializedName("HashTag")
91     private String hashTag;
92     @SerializedName("ConversionRate")
93     private float conversionRate;
94     @SerializedName("AllRoundsAdded")
95     private boolean allRoundsAdded;
96     @SerializedName("PhotoURLs")
97     private String photoUrls;
98     @SerializedName("NumCompetitors")
99     private int numCompetitors;
100     @SerializedName("NumUpcoming")
101     private int numUpcoming;
102     @SerializedName("NumActive")
103     private int numActive;
104     @SerializedName("NumResults")
105     private int numResults;
106     @SerializedName("Note")
107     private String note;
108     @SerializedName("CommonNote")
109     private String commonNote;
110     @SerializedName("DefendingChampion")
111     private int defendingChampion;
112     @SerializedName("PreviousEdition")
113     private int previousEdition;
114
115     @Override
116     public int eventId() {
117         return eventId;
118     }
119
120     @Override
121     public String name() {
122         return name;
123     }
124
125     @Override
126     public Date startDate() {
127         return startDate;
128     }
129
130     @Override
131     public Date endDate() {
132         return endDate;
133     }
134
135     @Override
136     public String sponsor() {
137         return sponsor;
138     }
139
140     @Override
141     public Season season() {
142         if (season == null)
143             season = Season.getSeason(seasonYear);
144         return season;
145     }
146
147     @Override
148     public String type() {
149         return type;
150     }
151
152     @Override
153     public int num() {
154         return num;
155     }
156
157     @Override
158     public String venue() {
159         return venue;
160     }
161
162     @Override
163     public String city() {
164         return city;
165     }
166
167     @Override
168     public String country() {
169         return country;
170     }
171
172     @Override
173     public String discipline() {
174         return discipline;
175     }
176
177     @Override
178     public int mainEventId() {
179         return mainEventId;
180     }
181
182     @Override
183     public Event mainEvent() {
184         if (mainEvent == null && mainEventId == eventId)
185             mainEvent = this;
186         return mainEvent;
187     }
188
189     public void setMainEvent(Event event) {
190         if (event != null && eventId == event.eventId())
191             mainEvent = event;
192     }
193
194     @Override
195     public String sex() {
196         return sex;
197     }
198
199     @Override
200     public String ageGroup() {
201         return ageGroup;
202     }
203
204     @Override
205     public String url() {
206         return url;
207     }
208
209     @Override
210     public String related() {
211         return related;
212     }
213
214     @Override
215     public String stage() {
216         return stage;
217     }
218
219     @Override
220     public String valueType() {
221         return valueType;
222     }
223
224     @Override
225     public String shortName() {
226         return shortName;
227     }
228
229     @Override
230     public int worldSnookerId() {
231         return worldSnookerId;
232     }
233
234     @Override
235     public String rankingType() {
236         return rankingType;
237     }
238
239     @Override
240     public int eventPredictionId() {
241         return eventPredictionId;
242     }
243
244     @Override
245     public boolean team() {
246         return team;
247     }
248
249     @Override
250     public int format() {
251         return format;
252     }
253
254     @Override
255     public String twitter() {
256         return twitter;
257     }
258
259     @Override
260     public String hashTag() {
261         return hashTag;
262     }
263
264     @Override
265     public float conversionRate() {
266         return conversionRate;
267     }
268
269     @Override
270     public boolean allRoundsAdded() {
271         return allRoundsAdded;
272     }
273
274     @Override
275     public String photoUrls() {
276         return photoUrls;
277     }
278
279     @Override
280     public int numCompetitors() {
281         return numCompetitors;
282     }
283
284     @Override
285     public int numUpcoming() {
286         return numUpcoming;
287     }
288
289     @Override
290     public int numActive() {
291         return numActive;
292     }
293
294     @Override
295     public int numResults() {
296         return numResults;
297     }
298
299     @Override
300     public String note() {
301         return note;
302     }
303
304     @Override
305     public String commonNote() {
306         return commonNote;
307     }
308
309     @Override
310     public int defendingChampion() {
311         return defendingChampion;
312     }
313
314     @Override
315     public int previousEdition() {
316         return previousEdition;
317     }
318
319     @Override
320     public int getId() {
321         return eventId;
322     }
323
324 }