[LIB-10] SerialVersionUID for Serializable classes
[snooker-score-api.git] / src / main / java / org / hedgecode / snooker / json / JsonSeeding.java
1 /*
2  * Copyright (c) 2017-2020. 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.io.Serializable;
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.Player;
26 import org.hedgecode.snooker.api.Seeding;
27
28 /**
29  * Seeding Entity to JSON deserialize.
30  *
31  * @author Dmitry Samoshin aka gotty
32  */
33 public class JsonSeeding extends JsonIdEntity implements Seeding, Serializable {
34
35     private static final long serialVersionUID = -9182126924854384725L;
36
37     @SerializedName("EventID")
38     private int eventId;
39     @Expose
40     private Event event;
41     @SerializedName("PlayerID")
42     private int playerId;
43     @Expose
44     private Player player;
45     @SerializedName("Seeding")
46     private int seeding;
47
48     JsonSeeding() {
49     }
50
51     @Override
52     public int eventId() {
53         return eventId;
54     }
55
56     @Override
57     public Event event() {
58         return event;
59     }
60
61     public void setEvent(Event event) {
62         if (event != null && eventId == event.eventId())
63             this.event = event;
64     }
65
66     @Override
67     public int playerId() {
68         return playerId;
69     }
70
71     @Override
72     public Player player() {
73         return player;
74     }
75
76     public void setPlayer(Player player) {
77         if (player != null && playerId == player.playerId())
78             this.player = player;
79     }
80
81     @Override
82     public int seeding() {
83         return seeding;
84     }
85
86     @Override
87     public int getId() {
88         return seeding;
89     }
90
91 }