Skip to content

Commit

Permalink
refactor: Use constant for the plus sign and use ComparableUtils
Browse files Browse the repository at this point in the history
  • Loading branch information
sgcr committed Sep 3, 2024
1 parent 4e26627 commit 9d5f114
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/main/java/tool/arenasizer/LabelWithSignedNumber.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@

import static java.math.BigDecimal.ZERO;
import static org.apache.commons.lang3.StringUtils.EMPTY;
import static org.apache.commons.lang3.compare.ComparableUtils.is;

class LabelWithSignedNumber extends JLabel {

private static final String PLUS_SIGN = "+";

private final String notAvailableString = HOVerwaltung.instance().getLanguageString("ls.general_label.not_available_abbreviation");

public LabelWithSignedNumber(String text, int horizontalAlignment) {
Expand Down Expand Up @@ -62,12 +65,12 @@ private static Color getColorFromCompareResult(int compareResult) {
}

private static String formatNumberWithSign(NumberFormat numberformat, int number) {
final String prefix = (number > 0) ? "+" : EMPTY;
final String prefix = (number > 0) ? PLUS_SIGN : EMPTY;
return prefix + numberformat.format(number);
}

private static String formatNumberWithSign(BigDecimal percentage) {
final String prefix = (percentage.compareTo(ZERO) > 0) ? "+" : EMPTY;
final String prefix = is(percentage).greaterThan(ZERO) ? PLUS_SIGN : EMPTY;
return prefix + percentageValueString(percentage);
}

Expand Down

0 comments on commit 9d5f114

Please sign in to comment.