--- /dev/null
+/*
+ * Copyright (c) 2017. 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.Player;
+import org.hedgecode.snooker.api.Ranking;
+import org.hedgecode.snooker.api.RankingType;
+import org.hedgecode.snooker.api.Season;
+
+/**
+ * Ranking Entity to JSON deserialize.
+ *
+ * @author Dmitry Samoshin aka gotty
+ */
+public class JsonRanking extends JsonIdEntity implements Ranking {
+
+ @SerializedName("ID")
+ private int rankingId;
+ @SerializedName("Position")
+ private int position;
+ @SerializedName("PlayerID")
+ private int playerId;
+ @Expose
+ private Player player;
+ @SerializedName("Season")
+ private int seasonYear;
+ @Expose
+ private Season season;
+ @SerializedName("Sum")
+ private long sum;
+ @SerializedName("Type")
+ private String type;
+ @Expose
+ private RankingType rankingType;
+
+ @Override
+ public int rankingId() {
+ return rankingId;
+ }
+
+ @Override
+ public int position() {
+ return position;
+ }
+
+ @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 Season season() {
+ if (season == null)
+ season = Season.getSeason(seasonYear);
+ return season;
+ }
+
+ @Override
+ public long sum() {
+ return sum;
+ }
+
+ @Override
+ public RankingType rankingType() {
+ if (rankingType == null)
+ rankingType = RankingType.byName(type);
+ return rankingType;
+ }
+
+ @Override
+ public int getId() {
+ return rankingId;
+ }
+
+}