MemSize implements Comparable<MemSize> { @NotNull public static MemSize valueOf(@NotNull String string) { return StringFormatUtils.parseMemSize(string); } private  MemSize(long bytes); @NotNull static MemSize of(long bytes); @NotNull static MemSize bytes(long bytes); @NotNull static MemSize kilobytes(long kilobytes); @NotNull static MemSize megabytes(long megabytes); @NotNull static MemSize gigabytes(long gigabytes); @NotNull static MemSize terabytes(long terabytes); long toLong(); int toInt(); @NotNull MemSize map(@NotNull Function<Long, Long> fn); @NotNull static MemSize valueOf(@NotNull String string); @NotNull String format(); @Override int compareTo(@NotNull MemSize o); @Override boolean equals(Object o); @Override int hashCode(); @NotNull @Override String toString(); static final MemSize ZERO; static final long KB; static final long MB; static final long GB; static final long TB; }
@Test public void testParsingExceptions() { exception.expect(IllegalArgumentException.class); exception.expectMessage("MemSize unit bytes cannot be fractional"); MemSize.valueOf("2.2b"); }