Skip to content

Commit

Permalink
update java version, use unnamed variables
Browse files Browse the repository at this point in the history
  • Loading branch information
akmsw committed May 10, 2024
1 parent de65f31 commit a682476
Show file tree
Hide file tree
Showing 38 changed files with 224 additions and 178 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ jobs:
runs-on: ubuntu-latest # Verificar que corra en Ubuntu es suficiente.
steps:
- uses: actions/checkout@v3
- name: Set up JDK 16+
- name: Set up JDK 22+
uses: actions/setup-java@v3
with:
java-version: '16'
java-version: '22'
distribution: 'temurin'
cache: maven
- name: Set up Maven version
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[![buildBadge](https://github.com/akmsw/armame-el-doparti/actions/workflows/maven.yml/badge.svg?branch=develop-v3.0)](https://github.com/akmsw/armame-el-doparti/actions/workflows/maven.yml)
[![issuesBadge](https://img.shields.io/github/issues/akmsw/armame-el-doparti.svg?logo=github)](https://github.com/akmsw/armame-el-doparti/issues)

[![openJDKTargetBadge](https://img.shields.io/badge/jdk-16%2B-red?logo=openjdk)](https://openjdk.org/projects/jdk/16/)
[![openJDKTargetBadge](https://img.shields.io/badge/jdk-22%2B-red?logo=openjdk)](https://openjdk.org/projects/jdk/22/)
[![operatingSystemBadge](https://img.shields.io/badge/os-cross--platform-blueviolet?logo=windows-terminal)](https://en.wikipedia.org/wiki/Cross-platform_software)
[![licenseBadge](https://img.shields.io/badge/gpl-3.0-blue?logo=gnu)](https://www.gnu.org/licenses/gpl-3.0.en.html)

Expand Down Expand Up @@ -38,9 +38,9 @@ Se ofrece la posibilidad de "anclar" dos o más jugadores entre sí, garantizand
## 📦 Requisitos generales
### ☕ Java
- #### Versión mínima
🟡 [Java 16](https://www.oracle.com/ar/java/technologies/javase/jdk16-archive-downloads.html)
🟡 [Java 22](https://www.oracle.com/ar/java/technologies/javase/jdk22-archive-downloads.html)
- #### Versión recomendada
🟢 [Java 21](https://www.oracle.com/java/technologies/javase/jdk21-archive-downloads.html) *(o más reciente)*
🟢 [Java 22](https://www.oracle.com/java/technologies/javase/jdk22-archive-downloads.html) *(o más reciente)*

## ⚙️ Requisitos para compilación manual
### 🪶 Apache Maven
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<version>3.0</version>

<properties>
<java.version>16</java.version>
<java.version>22</java.version>
<maven.version>3.9.6</maven.version>
<maven-compiler.version>3.11.0</maven-compiler.version>
<maven-enforcer.version>3.2.1</maven-enforcer.version>
Expand Down
21 changes: 15 additions & 6 deletions src/main/java/armameeldoparti/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
*/
public final class Main {

// --------------------------------------------------------------- Constructor ---------------------------------------------------------------------
// ---------- Constructor --------------------------------------------------------------------------------------------------------------------------

/**
* Empty, private constructor.
Expand All @@ -57,7 +57,7 @@ private Main() {
// Body not needed
}

// --------------------------------------------------------------- Main entry point ----------------------------------------------------------------
// ---------- Main entry point ---------------------------------------------------------------------------------------------------------------------

/**
* Starts the program by initializing the fields needed along with the program's graphical properties, and making the main menu
Expand Down Expand Up @@ -87,17 +87,20 @@ public static void main(String[] args) {
SwingUtilities.invokeLater(((MainMenuController) CommonFunctions.getController(ProgramView.MAIN_MENU))::showView);
}

// ---------------------------------------------------------------- Private methods ----------------------------------------------------------------
// ---------- Private methods ----------------------------------------------------------------------------------------------------------------------

/**
* Populates the players sets with empty players.
*
* <p>The "java:S1190" and "java:S117" warnings are suppressed since JDK22 allows the use of unnamed variables.
*/
@SuppressWarnings({"java:S1190", "java:S117"})
private static void populatePlayersSets() {
Arrays.stream(Position.values())
.forEach(position -> CommonFields.getPlayersSets()
.put(position, IntStream.range(0, CommonFields.getPlayersAmountMap()
.get(position) * 2)
.mapToObj(i -> new Player("", position))
.mapToObj(_ -> new Player("", position))
.toList()));
}

Expand All @@ -113,7 +116,10 @@ private static void populatePlayersSets() {
* trusts that what is found corresponds to the order in which the values in the Position enum are declared. Idem, if the order of the Position enum
* values are changed, it should be noted that {@code Position.values()[index]} trusts the order in which the data will be retrieved from the .pda
* file and, therefore, you should review the order of the important lines in the file.
*
* <p>The "java:S1190" warning is suppressed since JDK22 allows the use of unnamed variables.
*/
@SuppressWarnings("java:S1190")
private static void setPlayersDistribution() {
try (BufferedReader buff = new BufferedReader(
new InputStreamReader(
Expand All @@ -132,7 +138,7 @@ private static void setPlayersDistribution() {
.put(Position.values()[index],
Integer.parseInt(filteredLines.get(index)
.replaceAll(Constants.REGEX_PLAYERS_AMOUNT, ""))));
} catch (IOException e) {
} catch (IOException _) {
CommonFunctions.exitProgram(Error.ERROR_FILES);
}
}
Expand All @@ -152,7 +158,10 @@ ProgramView.SKILL_POINTS, new SkillPointsInputController(new SkillPointsInputVie

/**
* Sets up the program's GUI properties.
*
* <p>The "java:S1190" warning is suppressed since JDK22 allows the use of unnamed variables.
*/
@SuppressWarnings("java:S1190")
private static void setUpGeneralGraphicalProperties() {
UIManager.put("Button.background", Constants.COLOR_GREEN_DARK);
UIManager.put("Button.foreground", Color.WHITE);
Expand Down Expand Up @@ -188,7 +197,7 @@ private static void setUpGeneralGraphicalProperties() {
.registerFont(programFont);

setProgramFont(programFont);
} catch (IOException | FontFormatException e) {
} catch (IOException | FontFormatException _) {
CommonFunctions.exitProgram(Error.ERROR_GUI);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
*/
public class AnchoragesController extends Controller<AnchoragesView> {

// ---------------------------------------------------------------- Private fields -----------------------------------------------------------------
// ---------- Private constants --------------------------------------------------------------------------------------------------------------------

private int anchoragesAmount;
private int anchoredPlayersAmount;

// --------------------------------------------------------------- Constructor ---------------------------------------------------------------------
// ---------- Constructor --------------------------------------------------------------------------------------------------------------------------

/**
* Builds the anchorages view controller.
Expand All @@ -44,7 +44,7 @@ public AnchoragesController(AnchoragesView anchoragesView) {
toggleButtons();
}

// ---------------------------------------------------------------- Public methods -----------------------------------------------------------------
// ---------- Public methods -----------------------------------------------------------------------------------------------------------------------

/**
* Updates the checkboxes text with the players names.
Expand Down Expand Up @@ -180,7 +180,7 @@ public void backButtonEvent() {
.showView();
}

// --------------------------------------------------------------- Protected methods ---------------------------------------------------------------
// ---------- Protected methods --------------------------------------------------------------------------------------------------------------------

/**
* Resets the controlled view to its default values.
Expand All @@ -205,7 +205,11 @@ protected void setUpInitialState() {
.setEnabled(false);
}

/**
* The "java:S1190" and "java:S117" warnings are suppressed since JDK22 allows the use of unnamed variables.
*/
@Override
@SuppressWarnings({"java:S1190", "java:S117"})
protected void setUpListeners() {
view.getFinishButton()
.addActionListener(e -> finishButtonEvent(CommonFunctions.getComponentFromEvent(e)));
Expand All @@ -214,14 +218,14 @@ protected void setUpListeners() {
view.getDeleteAnchorageButton()
.addActionListener(e -> deleteAnchorageButtonEvent(CommonFunctions.getComponentFromEvent(e)));
view.getDeleteLastAnchorageButton()
.addActionListener(e -> deleteLastAnchorageButtonEvent());
.addActionListener(_ -> deleteLastAnchorageButtonEvent());
view.getClearAnchoragesButton()
.addActionListener(e -> clearAnchoragesButtonEvent());
.addActionListener(_ -> clearAnchoragesButtonEvent());
view.getBackButton()
.addActionListener(e -> backButtonEvent());
.addActionListener(_ -> backButtonEvent());
}

// ---------------------------------------------------------------- Private methods ----------------------------------------------------------------
// ---------- Private methods ----------------------------------------------------------------------------------------------------------------------

/**
* Sets a new anchorage based on the players checked.
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/armameeldoparti/controllers/Controller.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
*/
public abstract class Controller<T extends View> {

// --------------------------------------------------------------- Protected fields ----------------------------------------------------------------
// ---------- Protected fields ---------------------------------------------------------------------------------------------------------------------

protected T view;

// --------------------------------------------------------------- Constructor ---------------------------------------------------------------------
// ---------- Constructor --------------------------------------------------------------------------------------------------------------------------

/**
* Builds the view controller.
Expand All @@ -31,7 +31,7 @@ protected Controller(T view) {
setView(view);
}

// --------------------------------------------------------------- Protected methods ---------------------------------------------------------------
// ---------- Protected methods --------------------------------------------------------------------------------------------------------------------

/**
* Centers the controlled view on the current active monitor.
Expand Down Expand Up @@ -65,7 +65,7 @@ protected void showView() {
view.setVisible(true);
}

// ---------------------------------------------------------- Abstract protected methods -----------------------------------------------------------
// ---------- Abstract protected methods -----------------------------------------------------------------------------------------------------------

/**
* Resets the controlled view to its default values.
Expand All @@ -82,13 +82,13 @@ protected void showView() {
*/
protected abstract void setUpListeners();

// -------------------------------------------------------------------- Getters --------------------------------------------------------------------
// ---------- Getters ------------------------------------------------------------------------------------------------------------------------------

protected T getView() {
return view;
}

// -------------------------------------------------------------------- Setters --------------------------------------------------------------------
// ---------- Setters ------------------------------------------------------------------------------------------------------------------------------

protected void setView(T view) {
this.view = view;
Expand Down
31 changes: 19 additions & 12 deletions src/main/java/armameeldoparti/controllers/HelpController.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@
*/
public class HelpController extends Controller<HelpView> {

// --------------------------------------------------------------- Private constants ---------------------------------------------------------------
// ---------- Private constants --------------------------------------------------------------------------------------------------------------------

private static final int TOTAL_HELP_PAGES = Constants.MAP_HELP_PAGES_FILES
.size();

// ---------------------------------------------------------------- Private fields -----------------------------------------------------------------
// ---------- Private constants --------------------------------------------------------------------------------------------------------------------

private int currentPageNumber;

// --------------------------------------------------------------- Constructor ---------------------------------------------------------------------
// ---------- Constructor --------------------------------------------------------------------------------------------------------------------------

/**
* Builds the help view controller.
Expand All @@ -46,7 +46,7 @@ public HelpController(HelpView helpView) {
setUpInitialState();
}

// ---------------------------------------------------------------- Public methods -----------------------------------------------------------------
// ---------- Public methods -----------------------------------------------------------------------------------------------------------------------

/**
* Resets the page to the beginning, makes the controlled view invisible and shows the main menu view.
Expand Down Expand Up @@ -93,7 +93,10 @@ public void previousPageButtonEvent() {
* Updates the displayed page in the text area.
*
* <p>Finds the text file corresponding to the page number and displays its content.
*
* <p>The "java:S1190" warning is suppressed since JDK22 allows the use of unnamed variables.
*/
@SuppressWarnings("java:S1190")
public void updatePage() {
JTextArea textArea = view.getTextArea();

Expand Down Expand Up @@ -122,12 +125,12 @@ public void updatePage() {
textArea.read(reader, null);
textArea.setCaretPosition(0);
textArea.scrollRectToVisible(new Rectangle(0, 0, 1, 1));
} catch (IOException e) {
} catch (IOException _) {
CommonFunctions.exitProgram(Error.ERROR_FILES);
}
}

// --------------------------------------------------------------- Protected methods ---------------------------------------------------------------
// ---------- Protected methods --------------------------------------------------------------------------------------------------------------------

@Override
protected void resetView() {
Expand All @@ -145,17 +148,21 @@ protected void setUpInitialState() {
.setEnabled(false);
}

/**
* The "java:S1190" and "java:S117" warnings are suppressed since JDK22 allows the use of unnamed variables.
*/
@Override
@SuppressWarnings({"java:S1190", "java:S117"})
protected void setUpListeners() {
view.getPreviousPageButton()
.addActionListener(e -> previousPageButtonEvent());
.addActionListener(_ -> previousPageButtonEvent());
view.getNextPageButton()
.addActionListener(e -> nextPageButtonEvent());
.addActionListener(_ -> nextPageButtonEvent());
view.getBackButton()
.addActionListener(e -> backButtonEvent());
.addActionListener(_ -> backButtonEvent());
}

// ---------------------------------------------------------------- Private methods ----------------------------------------------------------------
// ---------- Private methods ----------------------------------------------------------------------------------------------------------------------

/**
* Updates the reading progress label text.
Expand All @@ -175,13 +182,13 @@ private void resetButtons() {
.setEnabled(true);
}

// -------------------------------------------------------------------- Getters --------------------------------------------------------------------
// ---------- Getters ------------------------------------------------------------------------------------------------------------------------------

public int getCurrentPageNumber() {
return currentPageNumber;
}

// -------------------------------------------------------------------- Setters --------------------------------------------------------------------
// ---------- Setters ------------------------------------------------------------------------------------------------------------------------------

public void setCurrentPageNumber(int currentPageNumber) {
this.currentPageNumber = currentPageNumber;
Expand Down
18 changes: 11 additions & 7 deletions src/main/java/armameeldoparti/controllers/MainMenuController.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
public class MainMenuController extends Controller<MainMenuView> {

// --------------------------------------------------------------- Constructor ---------------------------------------------------------------------
// ---------- Constructor --------------------------------------------------------------------------------------------------------------------------

/**
* Builds the main menu view controller.
Expand All @@ -28,7 +28,7 @@ public MainMenuController(MainMenuView mainMenuView) {
setUpListeners();
}

// ---------------------------------------------------------------- Public methods -----------------------------------------------------------------
// ---------- Public methods -----------------------------------------------------------------------------------------------------------------------

@Override
public void showView() {
Expand Down Expand Up @@ -71,7 +71,7 @@ public void issuesButtonEvent() {
CommonFunctions.browserRedirect(Constants.URL_ISSUES);
}

// --------------------------------------------------------------- Protected methods ---------------------------------------------------------------
// ---------- Protected methods --------------------------------------------------------------------------------------------------------------------

@Override
protected void resetView() {
Expand All @@ -83,15 +83,19 @@ protected void setUpInitialState() {
// Body not needed in this particular controller
}

/**
* The "java:S1190" and "java:S117" warnings are suppressed since JDK22 allows the use of unnamed variables.
*/
@Override
@SuppressWarnings({"java:S1190", "java:S117"})
protected void setUpListeners() {
view.getStartButton()
.addActionListener(e -> startButtonEvent());
.addActionListener(_ -> startButtonEvent());
view.getHelpButton()
.addActionListener(e -> helpButtonEvent());
.addActionListener(_ -> helpButtonEvent());
view.getContactButton()
.addActionListener(e -> contactButtonEvent());
.addActionListener(_ -> contactButtonEvent());
view.getIssuesButton()
.addActionListener(e -> issuesButtonEvent());
.addActionListener(_ -> issuesButtonEvent());
}
}
Loading

0 comments on commit a682476

Please sign in to comment.