@Test public void toSizeUnitInputNullOutputNotNull() { final Long size = null; final String retval = Formats.toSizeUnit(size); Assert.assertEquals("NaN", retval); }
public static String toSizeUnit(Long size) { if (size == null) { return "NaN"; } if (size < KB_SIZE) { return size.toString(); } if (size < MB_SIZE) { return (size / KB_SIZE) + "k"; } if (size < GB_SIZE) { return (size / MB_SIZE) + "m"; } if (size < TB_SIZE) { return (size / GB_SIZE) + "g"; } return (size / TB_SIZE) + "t"; }
Formats { public static String toSizeUnit(Long size) { if (size == null) { return "NaN"; } if (size < KB_SIZE) { return size.toString(); } if (size < MB_SIZE) { return (size / KB_SIZE) + "k"; } if (size < GB_SIZE) { return (size / MB_SIZE) + "m"; } if (size < TB_SIZE) { return (size / GB_SIZE) + "g"; } return (size / TB_SIZE) + "t"; } }
Formats { public static String toSizeUnit(Long size) { if (size == null) { return "NaN"; } if (size < KB_SIZE) { return size.toString(); } if (size < MB_SIZE) { return (size / KB_SIZE) + "k"; } if (size < GB_SIZE) { return (size / MB_SIZE) + "m"; } if (size < TB_SIZE) { return (size / GB_SIZE) + "g"; } return (size / TB_SIZE) + "t"; }  }
Formats { public static String toSizeUnit(Long size) { if (size == null) { return "NaN"; } if (size < KB_SIZE) { return size.toString(); } if (size < MB_SIZE) { return (size / KB_SIZE) + "k"; } if (size < GB_SIZE) { return (size / MB_SIZE) + "m"; } if (size < TB_SIZE) { return (size / GB_SIZE) + "g"; } return (size / TB_SIZE) + "t"; }  static void disableAnsi(); static void setCleanClearTerminal(); static void setTextClearTerminal(); static String toMBWithColor(long bytes, LongWarning warning); static String toColor(long value, LongWarning warning); static String red(String value); static String yellow(String value); static String toMB(long bytes); static String toSizeUnitWithColor(Long size, LongWarning warning); static String toSizeUnit(Long size); static String toFixLengthSizeUnit(Long size); static String toTimeUnit(long millis); static String formatUsage(Usage usage); static String formatUsageWithColor(Usage usage, LongWarning warning); static String[] colorAnsi(long value, LongWarning warning); static String[] colorAnsi(double value, DoubleWarning warning); static String rightStr(String str, int length); static String leftStr(String str, int length); static String shortName(String str, int length, int rightLength); static String join(List<String> list, String delim); static long parseFromSize(String str); static void clearTerminal(); }
Formats { public static String toSizeUnit(Long size) { if (size == null) { return "NaN"; } if (size < KB_SIZE) { return size.toString(); } if (size < MB_SIZE) { return (size / KB_SIZE) + "k"; } if (size < GB_SIZE) { return (size / MB_SIZE) + "m"; } if (size < TB_SIZE) { return (size / GB_SIZE) + "g"; } return (size / TB_SIZE) + "t"; }  static void disableAnsi(); static void setCleanClearTerminal(); static void setTextClearTerminal(); static String toMBWithColor(long bytes, LongWarning warning); static String toColor(long value, LongWarning warning); static String red(String value); static String yellow(String value); static String toMB(long bytes); static String toSizeUnitWithColor(Long size, LongWarning warning); static String toSizeUnit(Long size); static String toFixLengthSizeUnit(Long size); static String toTimeUnit(long millis); static String formatUsage(Usage usage); static String formatUsageWithColor(Usage usage, LongWarning warning); static String[] colorAnsi(long value, LongWarning warning); static String[] colorAnsi(double value, DoubleWarning warning); static String rightStr(String str, int length); static String leftStr(String str, int length); static String shortName(String str, int length, int rightLength); static String join(List<String> list, String delim); static long parseFromSize(String str); static void clearTerminal(); static final long MB_SIZE; static boolean isWindows; }