Java Code Examples for com.google.common.math.LongMath#checkedSubtract()

The following examples show how to use com.google.common.math.LongMath#checkedSubtract() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Fiat.java    From bcm-android with GNU General Public License v3.0 4 votes vote down vote up
public Fiat subtract(final Fiat value) {
    checkArgument(value.currencyCode.equals(currencyCode));
    return new Fiat(currencyCode, LongMath.checkedSubtract(this.value, value.value));
}
 
Example 2
Source File: Coin.java    From bcm-android with GNU General Public License v3.0 4 votes vote down vote up
public Coin subtract(final Coin value) {
    return new Coin(LongMath.checkedSubtract(this.value, value.value));
}
 
Example 3
Source File: Altcoin.java    From bisq-core with GNU Affero General Public License v3.0 4 votes vote down vote up
public Altcoin subtract(final Altcoin value) {
    checkArgument(value.currencyCode.equals(currencyCode));
    return new Altcoin(currencyCode, LongMath.checkedSubtract(this.value, value.value));
}
 
Example 4
Source File: Fiat.java    From green_android with GNU General Public License v3.0 4 votes vote down vote up
public Fiat subtract(final Fiat value) {
    checkArgument(value.currencyCode.equals(currencyCode));
    return new Fiat(currencyCode, LongMath.checkedSubtract(this.value, value.value));
}
 
Example 5
Source File: Coin.java    From green_android with GNU General Public License v3.0 4 votes vote down vote up
public Coin subtract(final Coin value) {
    return new Coin(LongMath.checkedSubtract(this.value, value.value));
}
 
Example 6
Source File: Fiat.java    From GreenBits with GNU General Public License v3.0 4 votes vote down vote up
public Fiat subtract(final Fiat value) {
    checkArgument(value.currencyCode.equals(currencyCode));
    return new Fiat(currencyCode, LongMath.checkedSubtract(this.value, value.value));
}
 
Example 7
Source File: Coin.java    From GreenBits with GNU General Public License v3.0 4 votes vote down vote up
public Coin subtract(final Coin value) {
    return new Coin(LongMath.checkedSubtract(this.value, value.value));
}
 
Example 8
Source File: Altcoin.java    From bisq with GNU Affero General Public License v3.0 4 votes vote down vote up
public Altcoin subtract(final Altcoin value) {
    checkArgument(value.currencyCode.equals(currencyCode));
    return new Altcoin(currencyCode, LongMath.checkedSubtract(this.value, value.value));
}
 
Example 9
Source File: GuavaLongMathUnitTest.java    From tutorials with MIT License 4 votes vote down vote up
@Test
public void whenCheckedSubstractTwoLongValues_shouldSubstractThemAndReturnTheResultIfNotOverflow() {
    long result = LongMath.checkedSubtract(4L, 1L);
    assertEquals(3L, result);
}
 
Example 10
Source File: GuavaLongMathUnitTest.java    From tutorials with MIT License 4 votes vote down vote up
@Test(expected = ArithmeticException.class)
public void gwhenCheckedSubstractTwoLongValues_shouldThrowArithmeticExceptionIfOverflow() {
    LongMath.checkedSubtract(Long.MAX_VALUE, -100);
}