rewrites to optionals

This commit is contained in:
ingmargoudt 2017-03-19 19:48:00 +01:00
parent 348faa345b
commit ff6c6405aa
28 changed files with 760 additions and 494 deletions

View file

@ -28,6 +28,7 @@
package mage.interfaces;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;
import mage.MageException;
@ -113,7 +114,7 @@ public interface MageServer {
boolean isTableOwner(String sessionId, UUID roomId, UUID tableId) throws MageException;
TableView getTable(UUID roomId, UUID tableId) throws MageException;
Optional<TableView> getTable(UUID roomId, UUID tableId) throws MageException;
List<TableView> getTables(UUID roomId) throws MageException;
@ -124,13 +125,13 @@ public interface MageServer {
void leaveChat(UUID chatId, String sessionId) throws MageException;
UUID getTableChatId(UUID tableId) throws MageException;
Optional<UUID> getTableChatId(UUID tableId) throws MageException;
UUID getGameChatId(UUID gameId) throws MageException;
Optional<UUID> getGameChatId(UUID gameId) throws MageException;
UUID getRoomChatId(UUID roomId) throws MageException;
Optional<UUID> getRoomChatId(UUID roomId) throws MageException;
UUID getTournamentChatId(UUID tournamentId) throws MageException;
Optional<UUID> getTournamentChatId(UUID tournamentId) throws MageException;
//room methods
UUID getMainRoomId() throws MageException;

View file

@ -600,7 +600,7 @@ public class SessionImpl implements Session {
}
@Override
public UUID getRoomChatId(UUID roomId) {
public Optional<UUID> getRoomChatId(UUID roomId) {
try {
if (isConnected()) {
return server.getRoomChatId(roomId);
@ -608,11 +608,11 @@ public class SessionImpl implements Session {
} catch (MageException ex) {
handleMageException(ex);
}
return null;
return Optional.empty();
}
@Override
public UUID getTableChatId(UUID tableId) {
public Optional<UUID> getTableChatId(UUID tableId) {
try {
if (isConnected()) {
return server.getTableChatId(tableId);
@ -620,11 +620,11 @@ public class SessionImpl implements Session {
} catch (MageException ex) {
handleMageException(ex);
}
return null;
return Optional.empty();
}
@Override
public UUID getGameChatId(UUID gameId) {
public Optional<UUID> getGameChatId(UUID gameId) {
try {
if (isConnected()) {
return server.getGameChatId(gameId);
@ -634,11 +634,11 @@ public class SessionImpl implements Session {
} catch (Throwable t) {
handleThrowable(t);
}
return null;
return Optional.empty();
}
@Override
public TableView getTable(UUID roomId, UUID tableId) {
public Optional<TableView> getTable(UUID roomId, UUID tableId) {
try {
if (isConnected()) {
return server.getTable(roomId, tableId);
@ -646,7 +646,7 @@ public class SessionImpl implements Session {
} catch (MageException ex) {
handleMageException(ex);
}
return null;
return Optional.empty();
}
@Override
@ -735,7 +735,7 @@ public class SessionImpl implements Session {
} catch (Throwable t) {
handleThrowable(t);
}
return null;
return new ArrayList<>();
}
@Override
@ -750,7 +750,7 @@ public class SessionImpl implements Session {
} catch (Throwable t) {
handleThrowable(t);
}
return null;
return new ArrayList<>();
}
@Override
@ -765,7 +765,7 @@ public class SessionImpl implements Session {
} catch (Throwable t) {
handleThrowable(t);
}
return null;
return new ArrayList<>();
}
@Override
@ -784,7 +784,7 @@ public class SessionImpl implements Session {
}
@Override
public UUID getTournamentChatId(UUID tournamentId) {
public Optional<UUID> getTournamentChatId(UUID tournamentId) {
try {
if (isConnected()) {
return server.getTournamentChatId(tournamentId);
@ -794,7 +794,7 @@ public class SessionImpl implements Session {
} catch (Throwable t) {
handleThrowable(t);
}
return null;
return Optional.empty();
}
@Override
@ -1420,7 +1420,7 @@ public class SessionImpl implements Session {
} catch (Throwable t) {
handleThrowable(t);
}
return null;
return new ArrayList<>();
}
@Override

View file

@ -27,6 +27,7 @@
*/
package mage.remote.interfaces;
import java.util.Optional;
import java.util.UUID;
/**
@ -34,13 +35,13 @@ import java.util.UUID;
*/
public interface ChatSession {
UUID getRoomChatId(UUID roomId);
Optional<UUID> getRoomChatId(UUID roomId);
UUID getTableChatId(UUID tableId);
Optional<UUID> getTableChatId(UUID tableId);
UUID getGameChatId(UUID gameId);
Optional<UUID> getGameChatId(UUID gameId);
UUID getTournamentChatId(UUID tournamentId);
Optional<UUID> getTournamentChatId(UUID tournamentId);
boolean joinChat(UUID chatId);

View file

@ -34,6 +34,7 @@ import mage.remote.MageRemoteException;
import mage.view.TableView;
import mage.view.TournamentView;
import java.util.Optional;
import java.util.UUID;
/**
@ -71,7 +72,7 @@ public interface PlayerActions {
boolean joinTable(UUID roomId, UUID tableId, String playerName, String playerType, int skill, DeckCardLists deckList, String password);
TableView getTable(UUID roomId, UUID tableId);
Optional<TableView> getTable(UUID roomId, UUID tableId);
TournamentView getTournament(UUID tournamentId) throws MageRemoteException;

View file

@ -29,6 +29,7 @@ package mage.remote.interfaces;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
import mage.remote.MageRemoteException;
import mage.view.MatchView;