From 310d87814d2bac019f05e6d2ee9b3e24034ff105 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Wed, 8 Jan 2025 15:01:36 -0600 Subject: [PATCH] Refactored ButtonLabelTooltipPair to use a record. Replaced the ButtonLabelTooltipPair class with a Java record for improved readability and conciseness. Updated method calls to directly use record accessors, reducing boilerplate code. --- .../gui/baseComponents/MHQDialogImmersive.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/MekHQ/src/mekhq/gui/baseComponents/MHQDialogImmersive.java b/MekHQ/src/mekhq/gui/baseComponents/MHQDialogImmersive.java index e9d3be225d..fa47da707f 100644 --- a/MekHQ/src/mekhq/gui/baseComponents/MHQDialogImmersive.java +++ b/MekHQ/src/mekhq/gui/baseComponents/MHQDialogImmersive.java @@ -258,9 +258,9 @@ private void populateOutOfCharacterPanel(String outOfCharacterMessage) { */ private void populateButtonPanel(List buttons) { for (ButtonLabelTooltipPair buttonStrings : buttons) { - JButton button = new JButton(buttonStrings.getBtnLabel()); + JButton button = new JButton(buttonStrings.btnLabel()); - String tooltip = buttonStrings.getBtnTooltip(); + String tooltip = buttonStrings.btnTooltip(); if (tooltip != null) { button.setToolTipText(tooltip); } @@ -378,10 +378,7 @@ public static StringBuilder getSpeakerDescription(Campaign campaign, Person spea * This class is useful for scenarios where you want to pair a button's display label * with an optional tooltip message. */ - public static class ButtonLabelTooltipPair { - private final String btnLabel; - private final String btnTooltip; - + public record ButtonLabelTooltipPair(String btnLabel, String btnTooltip) { /** * Constructs a ButtonLabelTooltipPair with the given label and tooltip. * @@ -402,7 +399,8 @@ public ButtonLabelTooltipPair(String btnLabel, @Nullable String btnTooltip) { * * @return The button label as a {@link String}. */ - public String getBtnLabel() { + @Override + public String btnLabel() { return btnLabel; } @@ -411,7 +409,8 @@ public String getBtnLabel() { * * @return The button tooltip as a {@link String}, or {@code null} if no tooltip is set. */ - public @Nullable String getBtnTooltip() { + @Override + public @Nullable String btnTooltip() { return btnTooltip; } }