Big refactoring (server)

I used Intellij IDEA to automatically refactor code to achive 3 goals.
1) get rid of anonymouse classes, and replace the with lamba to get more readeable and clean code (like in TableWaitingDialog).
2) make effectively final  variables actually final to avoid inadvertent changes on it in further releases and keep objects as immutable, as possible.
3)  Get rid of unused imports (most of the changes) in whole project classes.
This commit is contained in:
vraskulin 2017-01-09 19:47:03 +03:00
parent 076840df53
commit 46d369c8ed
31 changed files with 510 additions and 822 deletions

View file

@ -90,7 +90,7 @@ public class TableController {
private Tournament tournament;
private ScheduledFuture<?> futureTimeout;
protected static ScheduledExecutorService timeoutExecutor = ThreadExecutor.getInstance().getTimeoutExecutor();
protected static final ScheduledExecutorService timeoutExecutor = ThreadExecutor.getInstance().getTimeoutExecutor();
public TableController(UUID roomId, UUID userId, MatchOptions options) {
this.userId = userId;
@ -128,20 +128,17 @@ public class TableController {
private void init() {
match.addTableEventListener(
new Listener<TableEvent>() {
@Override
public void event(TableEvent event) {
try {
switch (event.getEventType()) {
case SIDEBOARD:
sideboard(event.getPlayerId(), event.getDeck());
break;
(Listener<TableEvent>) event -> {
try {
switch (event.getEventType()) {
case SIDEBOARD:
sideboard(event.getPlayerId(), event.getDeck());
break;
}
} catch (MageException ex) {
logger.fatal("Table event listener error", ex);
}
} catch (MageException ex) {
logger.fatal("Table event listener error", ex);
}
}
}
);
}
@ -814,12 +811,7 @@ public class TableController {
cancelTimeout();
if (seconds > 0) {
futureTimeout = timeoutExecutor.schedule(
new Runnable() {
@Override
public void run() {
autoSideboard();
}
},
() -> autoSideboard(),
seconds, TimeUnit.SECONDS
);
}