Java language level migrations

This commit is contained in:
Hamidreza Bayat 2020-03-27 19:20:30 +04:30
parent 16b57176b6
commit c4575a67d9
9 changed files with 14 additions and 24 deletions

View File

@ -138,7 +138,7 @@ public class AppletGUI extends javax.swing.JApplet implements GUIInterface {
NewGame.setText("New Game"); NewGame.setText("New Game");
NewGame.setFocusable(false); NewGame.setFocusable(false);
NewGame.addActionListener(evt -> NewGameActionPerformed(evt)); NewGame.addActionListener(this::NewGameActionPerformed);
SettingsPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Settings")); SettingsPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Settings"));
SettingsPanel.setFocusable(false); SettingsPanel.setFocusable(false);
@ -161,15 +161,15 @@ public class AppletGUI extends javax.swing.JApplet implements GUIInterface {
TimeSlider.setPaintTicks(true); TimeSlider.setPaintTicks(true);
TimeSlider.setValue(5); TimeSlider.setValue(5);
TimeSlider.setFocusable(false); TimeSlider.setFocusable(false);
TimeSlider.addChangeListener(evt -> TimeSliderStateChanged(evt)); TimeSlider.addChangeListener(this::TimeSliderStateChanged);
ShowThinking.setText("Show Thinking"); ShowThinking.setText("Show Thinking");
ShowThinking.setFocusable(false); ShowThinking.setFocusable(false);
ShowThinking.addChangeListener(evt -> ShowThinkingStateChanged(evt)); ShowThinking.addChangeListener(this::ShowThinkingStateChanged);
FlipBoard.setText("Flip Board"); FlipBoard.setText("Flip Board");
FlipBoard.setFocusable(false); FlipBoard.setFocusable(false);
FlipBoard.addChangeListener(evt -> FlipBoardStateChanged(evt)); FlipBoard.addChangeListener(this::FlipBoardStateChanged);
javax.swing.GroupLayout SettingsPanelLayout = new javax.swing.GroupLayout(SettingsPanel); javax.swing.GroupLayout SettingsPanelLayout = new javax.swing.GroupLayout(SettingsPanel);
SettingsPanel.setLayout(SettingsPanelLayout); SettingsPanel.setLayout(SettingsPanelLayout);
@ -215,13 +215,13 @@ public class AppletGUI extends javax.swing.JApplet implements GUIInterface {
Forward.setDefaultCapable(false); Forward.setDefaultCapable(false);
Forward.setFocusPainted(false); Forward.setFocusPainted(false);
Forward.setFocusable(false); Forward.setFocusable(false);
Forward.addActionListener(evt -> ForwardActionPerformed(evt)); Forward.addActionListener(this::ForwardActionPerformed);
Backward.setText("<-"); Backward.setText("<-");
Backward.setDefaultCapable(false); Backward.setDefaultCapable(false);
Backward.setFocusPainted(false); Backward.setFocusPainted(false);
Backward.setFocusable(false); Backward.setFocusable(false);
Backward.addActionListener(evt -> BackwardActionPerformed(evt)); Backward.addActionListener(this::BackwardActionPerformed);
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout); jPanel1.setLayout(jPanel1Layout);

View File

@ -179,9 +179,7 @@ public class ChessBoardPainter extends JLabel {
try { try {
Font font = Font.createFont(Font.TRUETYPE_FONT, inStream); Font font = Font.createFont(Font.TRUETYPE_FONT, inStream);
chessFont = font.deriveFont((float)sqSize); chessFont = font.deriveFont((float)sqSize);
} catch (FontFormatException ex) { } catch (FontFormatException | IOException ex) {
throw new RuntimeException();
} catch (IOException ex) {
throw new RuntimeException(); throw new RuntimeException();
} }
} }

View File

@ -147,12 +147,9 @@ public class TUIGame extends Game {
return false; return false;
} catch (IOException ex) { } catch (IOException ex) {
System.out.printf("IO error: %s\n", ex.getMessage()); System.out.printf("IO error: %s\n", ex.getMessage());
} catch (ChessParseError cpe) { } catch (ChessParseError | StringIndexOutOfBoundsException cpe) {
int lineNo = (fr == null) ? -1 : fr.getLineNumber(); int lineNo = (fr == null) ? -1 : fr.getLineNumber();
System.out.printf("Parse error, line %d: %s\n", lineNo, cpe.getMessage()); System.out.printf("Parse error, line %d: %s\n", lineNo, cpe.getMessage());
} catch (StringIndexOutOfBoundsException e) {
int lineNo = (fr == null) ? -1 : fr.getLineNumber();
System.out.printf("Parse error, line %d: %s\n", lineNo, e.getMessage());
} finally { } finally {
if (fr != null) { if (fr != null) {
try { try {

View File

@ -199,9 +199,7 @@ public class UCIProtocol {
} }
quit = true; quit = true;
} }
} catch (ChessParseError ignore) { } catch (ChessParseError | ArrayIndexOutOfBoundsException | NumberFormatException ignore) {
} catch (ArrayIndexOutOfBoundsException ignore) {
} catch (NumberFormatException ignore) {
} }
} }

View File

@ -112,7 +112,7 @@ public class GameAdapter<T> extends BaseAdapter implements Filterable {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
protected void publishResults(CharSequence constraint, FilterResults results) { protected void publishResults(CharSequence constraint, FilterResults results) {
values = results == null ? new ArrayList<T>() : (ArrayList<T>) results.values; values = results == null ? new ArrayList<>() : (ArrayList<T>) results.values;
notifyDataSetChanged(); notifyDataSetChanged();
} }
} }

View File

@ -93,9 +93,7 @@ public class LoadFEN extends ListActivity {
workThread = new Thread(() -> { workThread = new Thread(() -> {
if (!readFile()) if (!readFile())
return; return;
runOnUiThread(() -> { runOnUiThread(lfen::showList);
lfen.showList();
});
}); });
workThread.start(); workThread.start();
} else if ("org.petero.droidfish.loadNextFen".equals(action) || } else if ("org.petero.droidfish.loadNextFen".equals(action) ||

View File

@ -41,7 +41,7 @@ final class InternalBook implements IOpeningBook {
private boolean enabled = false; private boolean enabled = false;
InternalBook() { InternalBook() {
Thread t = new Thread(() -> initInternalBook()); Thread t = new Thread(this::initInternalBook);
t.setPriority(Thread.MIN_PRIORITY); t.setPriority(Thread.MIN_PRIORITY);
t.start(); t.start();
} }

View File

@ -1000,7 +1000,7 @@ public class DroidComputerPlayer {
} }
if (havePvData) { if (havePvData) {
while (statPvInfo.size() < pvNum) while (statPvInfo.size() < pvNum)
statPvInfo.add(new PvInfo(0, 0, 0, 0, 0, 0, 0, 0, false, false, false, new ArrayList<Move>())); statPvInfo.add(new PvInfo(0, 0, 0, 0, 0, 0, 0, 0, false, false, false, new ArrayList<>()));
if (statPvInfo.size() == pvNum) if (statPvInfo.size() == pvNum)
statPvInfo.add(null); statPvInfo.add(null);
ArrayList<Move> moves = new ArrayList<>(); ArrayList<Move> moves = new ArrayList<>();

View File

@ -62,8 +62,7 @@ public class EngineServer implements ErrorHandler {
String arguments = prop.getProperty("arguments" + i, ""); String arguments = prop.getProperty("arguments" + i, "");
configs[i] = new EngineConfig(enabled, port, filename, arguments); configs[i] = new EngineConfig(enabled, port, filename, arguments);
} }
} catch (IOException ignore) { } catch (IOException | NumberFormatException ignore) {
} catch (NumberFormatException ignore) {
} }
} }