From f46fc1e9d85d555cd557eefa10e1211f9ad1ceb1 Mon Sep 17 00:00:00 2001 From: xander Date: Thu, 1 Sep 2022 20:23:00 +0100 Subject: CI stuff rename binding functions and format numbers with commas --- .../yacl/impl/utils/NumberFormatHelper.java | 38 ---------------------- 1 file changed, 38 deletions(-) delete mode 100644 src/main/java/dev/isxander/yacl/impl/utils/NumberFormatHelper.java (limited to 'src/main/java/dev/isxander/yacl/impl/utils') diff --git a/src/main/java/dev/isxander/yacl/impl/utils/NumberFormatHelper.java b/src/main/java/dev/isxander/yacl/impl/utils/NumberFormatHelper.java deleted file mode 100644 index bbf44a1..0000000 --- a/src/main/java/dev/isxander/yacl/impl/utils/NumberFormatHelper.java +++ /dev/null @@ -1,38 +0,0 @@ -package dev.isxander.yacl.impl.utils; - -import org.jetbrains.annotations.ApiStatus; - -import java.util.Map; -import java.util.NavigableMap; -import java.util.TreeMap; - -@ApiStatus.Internal -public class NumberFormatHelper { - private static final NavigableMap suffixes = new TreeMap<>(); - static { - suffixes.put(1_000L, "K"); - suffixes.put(1_000_000L, "M"); - suffixes.put(1_000_000_000L, "B"); - suffixes.put(1_000_000_000_000L, "T"); - suffixes.put(1_000_000_000_000_000L, "P"); - suffixes.put(1_000_000_000_000_000_000L, "E"); - } - - /** - * @author assylias - */ - public static String formatSmaller(long value) { - // Long.MIN_VALUE == -Long.MIN_VALUE, so we need an adjustment here - if (value == Long.MIN_VALUE) return formatSmaller(Long.MIN_VALUE + 1); - if (value < 0) return "-" + formatSmaller(-value); - if (value < 1000) return Long.toString(value); //deal with easy case - - Map.Entry e = suffixes.floorEntry(value); - Long divideBy = e.getKey(); - String suffix = e.getValue(); - - long truncated = value / (divideBy / 10); //the number part of the output times 10 - boolean hasDecimal = truncated < 100 && (truncated / 10d) != (truncated / 10); - return hasDecimal ? (truncated / 10d) + suffix : (truncated / 10) + suffix; - } -} -- cgit