@Test public void test_parse_decimal() { assertThat( () -> Measure.parse("1.5MB", MemoryUnit.class), is(throwing(instanceOf(IllegalArgumentException.class)) .andMessage(is(equalTo("Invalid measure: '1.5'. <quantity> must be a positive integer."))))); assertThat( () -> Measure.parse("1.5B", MemoryUnit.class), is(throwing(instanceOf(IllegalArgumentException.class)) .andMessage(is(equalTo("Invalid measure: '1.5'. <quantity> must be a positive integer."))))); assertThat( () -> Measure.parse("1.5", MemoryUnit.class), is(throwing(instanceOf(IllegalArgumentException.class)).andMessage(is(equalTo("Invalid measure: '1.5'. <unit> is missing or not recognized. It must be one of [B, KB, MB, GB, TB, PB]."))))); assertThat( () -> Measure.parse("1e5", MemoryUnit.class), is(throwing(instanceOf(IllegalArgumentException.class)).andMessage(is(equalTo("Invalid measure: '1e5'. <unit> is missing or not recognized. It must be one of [B, KB, MB, GB, TB, PB]."))))); assertThat( () -> Measure.parse("1E5", MemoryUnit.class), is(throwing(instanceOf(IllegalArgumentException.class)).andMessage(is(equalTo("Invalid measure: '1E5'. <unit> is missing or not recognized. It must be one of [B, KB, MB, GB, TB, PB]."))))); assertThat( () -> Measure.parse("1x5", MemoryUnit.class), is(throwing(instanceOf(IllegalArgumentException.class)).andMessage(is(equalTo("Invalid measure: '1x5'. <unit> is missing or not recognized. It must be one of [B, KB, MB, GB, TB, PB]."))))); }
public static <U extends Enum<U> & Unit<U>> Measure<U> parse(String quantityUnit, Class<U> unitType) throws IllegalArgumentException { return parse(quantityUnit, unitType, EnumSet.allOf(unitType)); }
Measure implements Comparable<Measure<T>> { public static <U extends Enum<U> & Unit<U>> Measure<U> parse(String quantityUnit, Class<U> unitType) throws IllegalArgumentException { return parse(quantityUnit, unitType, EnumSet.allOf(unitType)); } }
Measure implements Comparable<Measure<T>> { public static <U extends Enum<U> & Unit<U>> Measure<U> parse(String quantityUnit, Class<U> unitType) throws IllegalArgumentException { return parse(quantityUnit, unitType, EnumSet.allOf(unitType)); } protected  Measure(BigInteger quantity, T unit); }
Measure implements Comparable<Measure<T>> { public static <U extends Enum<U> & Unit<U>> Measure<U> parse(String quantityUnit, Class<U> unitType) throws IllegalArgumentException { return parse(quantityUnit, unitType, EnumSet.allOf(unitType)); } protected  Measure(BigInteger quantity, T unit); static Measure<U> of(long quantity, U type); static Measure<U> of(BigInteger quantity, U type); static Measure<U> zero(Class<U> unitType); static Measure<U> parse(String quantityUnit, Class<U> unitType); static Measure<U> parse(String quantityUnit, Class<U> unitType, Collection<U> validUnits); long getQuantity(); long getQuantity(T unit); BigInteger getExactQuantity(); BigInteger getExactQuantity(T unit); Measure<T> to(T unit); T getUnit(); Measure<T> add(long quantity, T unit); Measure<T> add(BigInteger quantity, T unit); Measure<T> add(long amount); Measure<T> add(BigInteger amount); Measure<T> multiply(long factor); Measure<T> multiply(BigInteger factor); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); @Override int compareTo(Measure<T> o); }
Measure implements Comparable<Measure<T>> { public static <U extends Enum<U> & Unit<U>> Measure<U> parse(String quantityUnit, Class<U> unitType) throws IllegalArgumentException { return parse(quantityUnit, unitType, EnumSet.allOf(unitType)); } protected  Measure(BigInteger quantity, T unit); static Measure<U> of(long quantity, U type); static Measure<U> of(BigInteger quantity, U type); static Measure<U> zero(Class<U> unitType); static Measure<U> parse(String quantityUnit, Class<U> unitType); static Measure<U> parse(String quantityUnit, Class<U> unitType, Collection<U> validUnits); long getQuantity(); long getQuantity(T unit); BigInteger getExactQuantity(); BigInteger getExactQuantity(T unit); Measure<T> to(T unit); T getUnit(); Measure<T> add(long quantity, T unit); Measure<T> add(BigInteger quantity, T unit); Measure<T> add(long amount); Measure<T> add(BigInteger amount); Measure<T> multiply(long factor); Measure<T> multiply(BigInteger factor); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); @Override int compareTo(Measure<T> o);  }