Value implements Monetary, Comparable<Value>, Serializable { public Value subtract(final Value value) { checkArgument(type.equals(value.type), "Cannot subtract a different type"); return new Value(this.type, LongMath.checkedSubtract(this.value, value.value)); } Value(final ValueType type, final long units); static Value valueOf(final ValueType type, final long units); static Value valueOf(final ValueType type, final Coin coin); @Override int smallestUnitExponent(); @Override long getValue(); Coin toCoin(); static Value valueOf(final ValueType type, final int coins, final int cents); static Value parse(final ValueType type, final String str); static Value parse(final ValueType type, final BigDecimal decimal); Value add(final Value value); Value add(final Coin value); Value subtract(final Value value); Value subtract(String str); Value multiply(final long factor); Value divide(final long divisor); Value[] divideAndRemainder(final long divisor); long divide(final Value divisor); boolean isPositive(); boolean isNegative(); boolean isZero(); boolean isGreaterThan(Value other); boolean isLessThan(Value other); Value shiftLeft(final int n); Value shiftRight(final int n); @Override int signum(); Value negate(); String toFriendlyString(); String toPlainString(); @Override String toString(); @Override boolean equals(final Object o); @Override int hashCode(); @Override int compareTo(@Nonnull final Value other); boolean isDust(); boolean isOfType(ValueType otherType); boolean isOfType(Value otherValue); boolean within(Value min, Value max); static Value max(Value value1, Value value2); static Value min(Value value1, Value value2); boolean canCompare(Value other); static boolean canCompare(@Nullable Value amount1, @Nullable Value amount2); final ValueType type; final long value; }
@Test(expected = IllegalArgumentException.class) public void testSubtractFail() { BTC.oneCoin().subtract(LTC.oneCoin()); }