Skip to content

Commit

Permalink
Enforce method reference usage for lambdas.
Browse files Browse the repository at this point in the history
  • Loading branch information
tsaglam committed Feb 4, 2024
1 parent 72d6413 commit 02d0236
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/main/java/carcassonne/model/tile/TileDistribution.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void setQuantity(TileType tileType, int quantity) {
*/
public void createBackup() {
restorationPoint.clear();
distribution.forEach((key, value) -> restorationPoint.put(key, value));
distribution.forEach(restorationPoint::put);
}

/**
Expand All @@ -58,7 +58,7 @@ public void createBackup() {
*/
public void restoreLastBackup() {
distribution.clear();
restorationPoint.forEach((key, value) -> distribution.put(key, value));
restorationPoint.forEach(restorationPoint::put);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/carcassonne/settings/GameSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ public void toggleMeepleRule(TerrainType type) {
private void notifyListeners() {
PaintShop.clearCachedImages();
for (NotifiableView notifiable : changeListeners) {
EventQueue.invokeLater(() -> notifiable.notifyChange());
EventQueue.invokeLater(notifiable::notifyChange);
}
}

Expand Down
4 changes: 1 addition & 3 deletions src/main/java/carcassonne/view/ViewFacade.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,7 @@ public void closeGameStatistics() {
*/
public Tile getSelectedTile() {
try {
EventQueue.invokeAndWait(() -> {
selectedTile = tileView.getSelectedTile();
});
EventQueue.invokeAndWait(() -> selectedTile = tileView.getSelectedTile());
} catch (InvocationTargetException | InterruptedException exception) {
exception.printStackTrace();
GameMessage.showError("Cannot retrieve selected tile:\n" + exception);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,7 @@ private List<JButton> createButtons() {
}, this::updateFromDistribution);
});
JButton resetButton = new JButton(RESET);
resetButton.addMouseListener((MouseClickListener) event -> {
ThreadingUtil.runAndCallback(() -> distribution.reset(), this::updateFromDistribution);
});
resetButton.addMouseListener((MouseClickListener) event -> ThreadingUtil.runAndCallback(distribution::reset, this::updateFromDistribution));
JButton acceptButton = new JButton(ACCEPT);
acceptButton.addMouseListener((MouseClickListener) event -> {
dispose();
Expand Down

0 comments on commit 02d0236

Please sign in to comment.