[LIB-8] Add Event Rounds and Seedings functional
[snooker-score-api.git] / src / main / java / org / hedgecode / snooker / json / JsonSeeding.java
1 /*
2  * Copyright (c) 2017-2019. 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 com.google.gson.annotations.Expose;
20 import com.google.gson.annotations.SerializedName;
21
22 import org.hedgecode.snooker.api.Event;
23 import org.hedgecode.snooker.api.Player;
24 import org.hedgecode.snooker.api.Seeding;
25
26 /**
27  * Seeding Entity to JSON deserialize.
28  *
29  * @author Dmitry Samoshin aka gotty
30  */
31 public class JsonSeeding extends JsonIdEntity implements Seeding {
32
33     @SerializedName("EventID")
34     private int eventId;
35     @Expose
36     private Event event;
37     @SerializedName("PlayerID")
38     private int playerId;
39     @Expose
40     private Player player;
41     @SerializedName("Seeding")
42     private int seeding;
43
44     protected JsonSeeding() {
45     }
46
47     @Override
48     public int eventId() {
49         return eventId;
50     }
51
52     @Override
53     public Event event() {
54         return event;
55     }
56
57     public void setEvent(Event event) {
58         if (event != null && eventId == event.eventId())
59             this.event = event;
60     }
61
62     @Override
63     public int playerId() {
64         return playerId;
65     }
66
67     @Override
68     public Player player() {
69         return player;
70     }
71
72     public void setPlayer(Player player) {
73         if (player != null && playerId == player.playerId())
74             this.player = player;
75     }
76
77     @Override
78     public int seeding() {
79         return seeding;
80     }
81
82     @Override
83     public int getId() {
84         return seeding;
85     }
86
87 }