@Test @SuppressWarnings("unchecked") public void testOrderingMixedUnits() { assertEquals( Lists.newArrayList( Amount.of(1, Data.BITS), Amount.of(1, Data.KB), Amount.of(1, Data.MB), Amount.of(1, Data.MB)), Ordering.natural().sortedCopy(Lists.newArrayList( Amount.of(1, Data.KB), Amount.of(1024, Data.KB), Amount.of(1, Data.BITS), Amount.of(1, Data.MB)))); }
public static <U extends Unit<U>> Amount<Double, U> of(double number, U unit) { return new Amount<Double, U>(number, unit, Double.MAX_VALUE) { @Override protected Double scale(double multiplier) { return getValue() * multiplier; } }; }
Amount implements Comparable<Amount<T, U>> { public static <U extends Unit<U>> Amount<Double, U> of(double number, U unit) { return new Amount<Double, U>(number, unit, Double.MAX_VALUE) { @Override protected Double scale(double multiplier) { return getValue() * multiplier; } }; } }
Amount implements Comparable<Amount<T, U>> { public static <U extends Unit<U>> Amount<Double, U> of(double number, U unit) { return new Amount<Double, U>(number, unit, Double.MAX_VALUE) { @Override protected Double scale(double multiplier) { return getValue() * multiplier; } }; } protected  Amount(T value, U unit, T maxValue); }
Amount implements Comparable<Amount<T, U>> { public static <U extends Unit<U>> Amount<Double, U> of(double number, U unit) { return new Amount<Double, U>(number, unit, Double.MAX_VALUE) { @Override protected Double scale(double multiplier) { return getValue() * multiplier; } }; } protected  Amount(T value, U unit, T maxValue); T getValue(); U getUnit(); T as(U unit); T asChecked(U unit); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString(); @Override int compareTo(Amount<T, U> other); static Amount<Double, U> of(double number, U unit); static Amount<Float, U> of(float number, U unit); static Amount<Long, U> of(long number, U unit); static Amount<Integer, U> of(int number, U unit); }
Amount implements Comparable<Amount<T, U>> { public static <U extends Unit<U>> Amount<Double, U> of(double number, U unit) { return new Amount<Double, U>(number, unit, Double.MAX_VALUE) { @Override protected Double scale(double multiplier) { return getValue() * multiplier; } }; } protected  Amount(T value, U unit, T maxValue); T getValue(); U getUnit(); T as(U unit); T asChecked(U unit); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString(); @Override int compareTo(Amount<T, U> other); static Amount<Double, U> of(double number, U unit); static Amount<Float, U> of(float number, U unit); static Amount<Long, U> of(long number, U unit); static Amount<Integer, U> of(int number, U unit);  }