diff --git a/drivers.utility/src/main/java/utility/CountingCLI.java b/drivers.utility/src/main/java/utility/CountingCLI.java index a639b2550..35e3708e8 100644 --- a/drivers.utility/src/main/java/utility/CountingCLI.java +++ b/drivers.utility/src/main/java/utility/CountingCLI.java @@ -198,16 +198,15 @@ private static Predicate notA(final Class cls) { return not(cls::isInstance); } - @SuppressWarnings("ChainOfInstanceofChecks") private static BigDecimal decimalize(final Number number) { - if (number instanceof Integer || number instanceof Long - || number instanceof Short || number instanceof Byte) { - return BigDecimal.valueOf(number.longValue()); - } else if (number instanceof final BigDecimal d) { - return d; - } else { - return BigDecimal.valueOf(number.doubleValue()); - } + return switch (number) { + case final Integer _ -> BigDecimal.valueOf(number.longValue()); + case final Long _ -> BigDecimal.valueOf(number.longValue()); + case final Short _ -> BigDecimal.valueOf(number.longValue()); + case final Byte _ -> BigDecimal.valueOf(number.longValue()); + case final BigDecimal d -> d; + default -> BigDecimal.valueOf(number.doubleValue()); + }; } private static Stream flatten(final Object item) {