import java.util.Collection;
import java.util.List;
-import static org.hedgecode.chess.scanner.ChessHogScannerConstants.*;
+import static org.hedgecode.chess.scanner.format.PGNConstants.*;
/**
* PGNTournament
sb.append(
game.pgn()
).append(
- CRLF
+ PGN_CRLF
);
}
return sb.toString();
--- /dev/null
+/*
+ * Copyright (c) 2019-2020. 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.chess.scanner.format.lichess;
+
+/**
+ * Clock
+ *
+ * @author Dmitry Samoshin aka gotty
+ */
+public interface Clock {
+
+ boolean running();
+
+ int initial();
+
+ int increment();
+
+ float white();
+
+ float black();
+
+ int emerg();
+
+ int moretime();
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2019-2020. 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.chess.scanner.format.lichess;
+
+import org.hedgecode.chess.scanner.spi.ServiceRegistry;
+
+/**
+ * Format
+ *
+ * @author Dmitry Samoshin aka gotty
+ */
+public final class Format {
+
+ private static Format _instance;
+
+ private final FormatBuilder formatBuilder;
+
+ private Format() {
+ formatBuilder = ServiceRegistry.singleProvider(
+ FormatBuilder.class
+ );
+ }
+
+ public static GameFormat formatGame(String game) {
+ return getFormat().builder().buildGame(game);
+ }
+
+ private FormatBuilder builder() {
+ return formatBuilder;
+ }
+
+ private static Format getFormat() {
+ if (_instance == null) {
+ _instance = new Format();
+ }
+ return _instance;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2019-2020. 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.chess.scanner.format.lichess;
+
+/**
+ * FormatBuilder
+ *
+ * @author Dmitry Samoshin aka gotty
+ */
+public interface FormatBuilder {
+
+ GameFormat buildGame(String game);
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2019-2020. 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.chess.scanner.format.lichess;
+
+/**
+ * Game
+ *
+ * @author Dmitry Samoshin aka gotty
+ */
+public interface Game {
+
+ String id();
+
+ String speed();
+
+ boolean rated();
+
+ String initialFen();
+
+ String fen();
+
+ String player();
+
+ int turns();
+
+ int startedAtTurn();
+
+ Status status();
+
+ long createdAt();
+
+ String winner();
+
+ String lastMove();
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2019-2020. 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.chess.scanner.format.lichess;
+
+import org.hedgecode.chess.scanner.format.Move;
+
+/**
+ * GameData
+ *
+ * @author Dmitry Samoshin aka gotty
+ */
+public interface GameData {
+
+ Game game();
+
+ Player player();
+
+ Player opponent();
+
+ Clock clock();
+
+ Move[] moves();
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2019-2020. 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.chess.scanner.format.lichess;
+
+import org.hedgecode.chess.scanner.entity.PGNEntity;
+
+/**
+ * GameFormat
+ *
+ * @author Dmitry Samoshin aka gotty
+ */
+public interface GameFormat extends PGNEntity {
+
+ String id();
+
+ GameData gameData();
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2019-2020. 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.chess.scanner.format.lichess;
+
+/**
+ * Player
+ *
+ * @author Dmitry Samoshin aka gotty
+ */
+public interface Player {
+
+ String color();
+
+ User user();
+
+ int rating();
+
+ int ratingDiff();
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2019-2020. 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.chess.scanner.format.lichess;
+
+/**
+ * Status
+ *
+ * @author Dmitry Samoshin aka gotty
+ */
+public interface Status {
+
+ String name();
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2019-2020. 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.chess.scanner.format.lichess;
+
+/**
+ * User
+ *
+ * @author Dmitry Samoshin aka gotty
+ */
+public interface User {
+
+ String id();
+
+ String username();
+
+}
@Override
public String id() {
return Integer.toString(
- gameData().game().id()
+ gameData.game().id()
);
}
return gameData;
}
-
@Override
public String pgn() {
PGNFormat pgnFormat = ServiceRegistry.singleProvider(
--- /dev/null
+/*
+ * Copyright (c) 2019-2020. 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.chess.scanner.json.lichess;
+
+import com.google.gson.annotations.SerializedName;
+
+import org.hedgecode.chess.scanner.format.lichess.Clock;
+
+/**
+ * JSONClock
+ *
+ * @author Dmitry Samoshin aka gotty
+ */
+public class JSONClock implements Clock {
+
+ @SerializedName("running")
+ private boolean running;
+
+ @SerializedName("initial")
+ private int initial;
+
+ @SerializedName("increment")
+ private int increment;
+
+ @SerializedName("white")
+ private float white;
+
+ @SerializedName("black")
+ private float black;
+
+ @SerializedName("emerg")
+ private int emerg;
+
+ @SerializedName("moretime")
+ private int moretime;
+
+ JSONClock() {
+ }
+
+ @Override
+ public boolean running() {
+ return running;
+ }
+
+ @Override
+ public int initial() {
+ return initial;
+ }
+
+ @Override
+ public int increment() {
+ return increment;
+ }
+
+ @Override
+ public float white() {
+ return white;
+ }
+
+ @Override
+ public float black() {
+ return black;
+ }
+
+ @Override
+ public int emerg() {
+ return emerg;
+ }
+
+ @Override
+ public int moretime() {
+ return moretime;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2019-2020. 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.chess.scanner.json.lichess;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+
+import org.hedgecode.chess.scanner.format.lichess.FormatBuilder;
+import org.hedgecode.chess.scanner.format.lichess.GameFormat;
+
+/**
+ * JSONFormatBuilder
+ *
+ * @author Dmitry Samoshin aka gotty
+ */
+public class JSONFormatBuilder implements FormatBuilder {
+
+ private static final Gson GSON = new GsonBuilder().create();
+
+ @Override
+ public GameFormat buildGame(String jsonGame) {
+ return GSON.fromJson(
+ jsonGame,
+ JSONGameFormat.class
+ );
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2019-2020. 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.chess.scanner.json.lichess;
+
+import com.google.gson.annotations.SerializedName;
+
+import org.hedgecode.chess.scanner.format.lichess.Game;
+import org.hedgecode.chess.scanner.format.lichess.Status;
+
+/**
+ * JSONGame
+ *
+ * @author Dmitry Samoshin aka gotty
+ */
+public class JSONGame implements Game {
+
+ @SerializedName("id")
+ private String id;
+
+ @SerializedName("speed")
+ private String speed;
+
+ @SerializedName("rated")
+ private boolean rated;
+
+ @SerializedName("initialFen")
+ private String initialFen;
+
+ @SerializedName("fen")
+ private String fen;
+
+ @SerializedName("player")
+ private String player;
+
+ @SerializedName("turns")
+ private int turns;
+
+ @SerializedName("startedAtTurn")
+ private int startedAtTurn;
+
+ @SerializedName("status")
+ private JSONStatus status;
+
+ @SerializedName("createdAt")
+ private long createdAt;
+
+ @SerializedName("winner")
+ private String winner;
+
+ @SerializedName("lastMove")
+ private String lastMove;
+
+ JSONGame() {
+ }
+
+ @Override
+ public String id() {
+ return id;
+ }
+
+ @Override
+ public String speed() {
+ return speed;
+ }
+
+ @Override
+ public boolean rated() {
+ return rated;
+ }
+
+ @Override
+ public String initialFen() {
+ return initialFen;
+ }
+
+ @Override
+ public String fen() {
+ return fen;
+ }
+
+ @Override
+ public String player() {
+ return player;
+ }
+
+ @Override
+ public int turns() {
+ return turns;
+ }
+
+ @Override
+ public int startedAtTurn() {
+ return startedAtTurn;
+ }
+
+ @Override
+ public Status status() {
+ return status;
+ }
+
+ @Override
+ public long createdAt() {
+ return createdAt;
+ }
+
+ @Override
+ public String winner() {
+ return winner;
+ }
+
+ @Override
+ public String lastMove() {
+ return lastMove;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2019-2020. 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.chess.scanner.json.lichess;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import com.google.gson.annotations.Expose;
+import com.google.gson.annotations.SerializedName;
+
+import org.hedgecode.chess.scanner.format.Move;
+import org.hedgecode.chess.scanner.format.lichess.Clock;
+import org.hedgecode.chess.scanner.format.lichess.Game;
+import org.hedgecode.chess.scanner.format.lichess.GameData;
+import org.hedgecode.chess.scanner.format.lichess.Player;
+
+/**
+ * JSONGameData
+ *
+ * @author Dmitry Samoshin aka gotty
+ */
+public class JSONGameData implements GameData {
+
+ private static final String PLAYER_WHITE = "white";
+ private static final String PLAYER_BLACK = "black";
+
+ private static final String GAME_DRAW = "draw";
+
+ private static final Map<String, String> RESULT = new HashMap<String, String>() {
+ {
+ put( PLAYER_WHITE, "1-0" );
+ put( PLAYER_BLACK, "0-1" );
+ put( GAME_DRAW, "1/2-1/2");
+ }
+ };
+
+ private static final Map<Boolean, String> RATED_GAME = new HashMap<Boolean, String>() {
+ {
+ put( Boolean.FALSE, "Unrated" );
+ put( Boolean.TRUE, "Rated" );
+ }
+ };
+
+ private static final String EVENT_GAME_FORMAT = "%s %s game";
+
+ @SerializedName("game")
+ private JSONGame game;
+
+ @SerializedName("player")
+ private JSONPlayer player;
+
+ @SerializedName("opponent")
+ private JSONPlayer opponent;
+
+ @SerializedName("clock")
+ private JSONClock clock;
+
+ @SerializedName("steps")
+ private JSONMove[] steps;
+
+ @SerializedName("treeParts")
+ private JSONMove[] treeParts;
+
+ @Expose
+ private Move[] moves;
+
+ JSONGameData() {
+ }
+
+ @Override
+ public Game game() {
+ return game;
+ }
+
+ @Override
+ public Player player() {
+ return player;
+ }
+
+ @Override
+ public Player opponent() {
+ return opponent;
+ }
+
+ public String event() {
+ return String.format(
+ EVENT_GAME_FORMAT,
+ RATED_GAME.get(game.rated()),
+ game.speed()
+ );
+ }
+
+ public Player white() {
+ return player.color().equals(PLAYER_WHITE)
+ ? player
+ : opponent.color().equals(PLAYER_WHITE)
+ ? opponent
+ : null;
+ }
+
+ public Player black() {
+ return player.color().equals(PLAYER_BLACK)
+ ? player
+ : opponent.color().equals(PLAYER_BLACK)
+ ? opponent
+ : null;
+ }
+
+ public String result() {
+ String result = null;
+ if (game.winner() != null) {
+ if (PLAYER_WHITE.equals(game.winner())) {
+ result = PLAYER_WHITE;
+ } else if (PLAYER_BLACK.equals(game.winner())) {
+ result = PLAYER_BLACK;
+ }
+ } else if (GAME_DRAW.equals(game.status().name())) {
+ result = GAME_DRAW;
+ }
+ return RESULT.get(result);
+ }
+
+ @Override
+ public Clock clock() {
+ return clock;
+ }
+
+ @Override
+ public Move[] moves() {
+ if (moves == null) {
+ moves = steps != null ? steps : treeParts;
+ List<Move> movesList = new ArrayList<>(Arrays.asList(moves));
+ movesList.removeIf(move -> move.move() == null);
+ moves = movesList.toArray(
+ new Move[movesList.size()]
+ );
+ }
+ return moves;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2019-2020. 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.chess.scanner.json.lichess;
+
+import java.util.Date;
+
+import com.google.gson.annotations.SerializedName;
+
+import org.hedgecode.chess.scanner.format.PGNFormat;
+import org.hedgecode.chess.scanner.format.PGNTag;
+import org.hedgecode.chess.scanner.format.TypeMovesFormat;
+import org.hedgecode.chess.scanner.format.lichess.GameData;
+import org.hedgecode.chess.scanner.format.lichess.GameFormat;
+import org.hedgecode.chess.scanner.spi.ServiceRegistry;
+
+/**
+ * JSONGameFormat
+ *
+ * @author Dmitry Samoshin aka gotty
+ */
+public class JSONGameFormat implements GameFormat {
+
+ private static final String TIME_CONTROL_FORMAT = "%d+%d";
+
+ @SerializedName("data")
+ private JSONGameData gameData;
+
+ JSONGameFormat() {
+ }
+
+ @Override
+ public String id() {
+ return gameData.game().id();
+ }
+
+ @Override
+ public GameData gameData() {
+ return gameData;
+ }
+
+ @Override
+ public String pgn() {
+ PGNFormat pgnFormat = ServiceRegistry.singleProvider(
+ PGNFormat.class
+ );
+ Date startDate = new Date(gameData.game().createdAt());
+ pgnFormat.addTag(PGNTag.EVENT, gameData.event());
+ pgnFormat.addTag(PGNTag.DATE, pgnFormat.formatDate(startDate));
+ pgnFormat.addTag(PGNTag.WHITE, gameData.white().user().username());
+ pgnFormat.addTag(PGNTag.BLACK, gameData.black().user().username());
+ pgnFormat.addTag(PGNTag.WHITE_ELO, Integer.toString(gameData.white().rating()));
+ pgnFormat.addTag(PGNTag.BLACK_ELO, Integer.toString(gameData.black().rating()));
+ pgnFormat.addTag(PGNTag.TIME, pgnFormat.formatTime(startDate));
+ pgnFormat.addTag(PGNTag.TIME_CONTROL,
+ String.format(
+ TIME_CONTROL_FORMAT, gameData.clock().initial(), gameData.clock().increment()
+ )
+ );
+ pgnFormat.addTag(PGNTag.RESULT, gameData.result());
+ if (gameData.game().turns() > 0) {
+ pgnFormat.addTag(PGNTag.PLY_COUNT, Integer.toString(gameData.game().turns()));
+ }
+ if (gameData.game().startedAtTurn() > 0) {
+ pgnFormat.addTag(PGNTag.FEN, gameData.game().fen());
+ }
+ pgnFormat.addMoves(
+ TypeMovesFormat.WRAP.format(gameData.moves())
+ );
+ return pgnFormat.format();
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2019-2020. 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.chess.scanner.json.lichess;
+
+import com.google.gson.annotations.SerializedName;
+
+import org.hedgecode.chess.scanner.format.Move;
+
+/**
+ * JSONMove
+ *
+ * @author Dmitry Samoshin aka gotty
+ */
+public class JSONMove implements Move {
+
+ @SerializedName("ply")
+ private int ply;
+
+ @SerializedName("uci")
+ private String uci;
+
+ @SerializedName("san")
+ private String san;
+
+ @SerializedName("fen")
+ private String fen;
+
+ JSONMove() {
+ }
+
+ @Override
+ public int ply() {
+ return ply;
+ }
+
+ @Override
+ public String move() {
+ return san;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2019-2020. 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.chess.scanner.json.lichess;
+
+import com.google.gson.annotations.SerializedName;
+
+import org.hedgecode.chess.scanner.format.lichess.Player;
+import org.hedgecode.chess.scanner.format.lichess.User;
+
+/**
+ * JSONPlayer
+ *
+ * @author Dmitry Samoshin aka gotty
+ */
+public class JSONPlayer implements Player {
+
+ @SerializedName("color")
+ private String color;
+
+ @SerializedName("user")
+ private JSONUser user;
+
+ @SerializedName("rating")
+ private int rating;
+
+ @SerializedName("ratingDiff")
+ private int ratingDiff;
+
+ JSONPlayer() {
+ }
+
+ @Override
+ public String color() {
+ return color;
+ }
+
+ @Override
+ public User user() {
+ return user;
+ }
+
+ @Override
+ public int rating() {
+ return rating;
+ }
+
+ @Override
+ public int ratingDiff() {
+ return ratingDiff;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2019-2020. 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.chess.scanner.json.lichess;
+
+import com.google.gson.annotations.SerializedName;
+
+import org.hedgecode.chess.scanner.format.lichess.Status;
+
+/**
+ * JSONStatus
+ *
+ * @author Dmitry Samoshin aka gotty
+ */
+public class JSONStatus implements Status {
+
+ @SerializedName("name")
+ private String name;
+
+ JSONStatus() {
+ }
+
+ @Override
+ public String name() {
+ return name;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2019-2020. 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.chess.scanner.json.lichess;
+
+import com.google.gson.annotations.SerializedName;
+
+import org.hedgecode.chess.scanner.format.lichess.User;
+
+/**
+ * JSONUser
+ *
+ * @author Dmitry Samoshin aka gotty
+ */
+public class JSONUser implements User {
+
+ @SerializedName("id")
+ private String id;
+
+ @SerializedName("username")
+ private String username;
+
+ JSONUser() {
+ }
+
+ @Override
+ public String id() {
+ return id;
+ }
+
+ @Override
+ public String username() {
+ return username;
+ }
+
+}
--- /dev/null
+org.hedgecode.chess.scanner.json.lichess.JSONFormatBuilder
\ No newline at end of file