[LIB-8] Add Event Rounds and Seedings functional
[snooker-score-api.git] / src / main / java / org / hedgecode / snooker / json / JsonSeeding.java
diff --git a/src/main/java/org/hedgecode/snooker/json/JsonSeeding.java b/src/main/java/org/hedgecode/snooker/json/JsonSeeding.java
new file mode 100644 (file)
index 0000000..6029450
--- /dev/null
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2017-2019. Developed by Hedgecode.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.hedgecode.snooker.json;
+
+import com.google.gson.annotations.Expose;
+import com.google.gson.annotations.SerializedName;
+
+import org.hedgecode.snooker.api.Event;
+import org.hedgecode.snooker.api.Player;
+import org.hedgecode.snooker.api.Seeding;
+
+/**
+ * Seeding Entity to JSON deserialize.
+ *
+ * @author Dmitry Samoshin aka gotty
+ */
+public class JsonSeeding extends JsonIdEntity implements Seeding {
+
+    @SerializedName("EventID")
+    private int eventId;
+    @Expose
+    private Event event;
+    @SerializedName("PlayerID")
+    private int playerId;
+    @Expose
+    private Player player;
+    @SerializedName("Seeding")
+    private int seeding;
+
+    protected JsonSeeding() {
+    }
+
+    @Override
+    public int eventId() {
+        return eventId;
+    }
+
+    @Override
+    public Event event() {
+        return event;
+    }
+
+    public void setEvent(Event event) {
+        if (event != null && eventId == event.eventId())
+            this.event = event;
+    }
+
+    @Override
+    public int playerId() {
+        return playerId;
+    }
+
+    @Override
+    public Player player() {
+        return player;
+    }
+
+    public void setPlayer(Player player) {
+        if (player != null && playerId == player.playerId())
+            this.player = player;
+    }
+
+    @Override
+    public int seeding() {
+        return seeding;
+    }
+
+    @Override
+    public int getId() {
+        return seeding;
+    }
+
+}