@Override public String convert(final GamePhase source) { //noinspection ConstantConditions return source != null ? source.toString() : null; }
@Override public GamePhase convert(final String source) { //noinspection ConstantConditions return source != null ? GamePhase.valueOf(source) : null; }
@GET @Path("phases") @Produces(MediaType.APPLICATION_JSON) public Map<GamePhase, List<String>> phasesAndDescriptions() { return Arrays.stream(GamePhase.values()) .collect(Collectors.toMap( p -> p, p -> Arrays.asList(p.getDescription(), p.getGroupLabel()))); } }
@Override protected IMPL handleActionInternal( final P player, final IMPL game, final Object param) { if (!game.getGamePhase().equals(GamePhase.RoundOver)) { throw new GameIsNotAvailableToRematchException(); } game.setGamePhase(GamePhase.NextRoundStarted); return game; } }