Skip to content

Commit

Permalink
Refactored ButtonLabelTooltipPair to use a record.
Browse files Browse the repository at this point in the history
Replaced the ButtonLabelTooltipPair class with a Java record for improved readability and conciseness. Updated method calls to directly use record accessors, reducing boilerplate code.
  • Loading branch information
IllianiCBT committed Jan 8, 2025
1 parent 0c35c27 commit 310d878
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions MekHQ/src/mekhq/gui/baseComponents/MHQDialogImmersive.java
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,9 @@ private void populateOutOfCharacterPanel(String outOfCharacterMessage) {
*/
private void populateButtonPanel(List<ButtonLabelTooltipPair> 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);
}
Expand Down Expand Up @@ -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.
*
Expand All @@ -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;
}

Expand All @@ -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;
}
}
Expand Down

0 comments on commit 310d878

Please sign in to comment.