Esempio n. 1
0
 /**
  * Computes and returns the sum of two cardinalities. If an overflow occurs, the maximum Long
  * value is returned (Long.MAX_VALUE).
  */
 public static long addCardinalities(long a, long b) {
   try {
     return LongMath.checkedAdd(a, b);
   } catch (ArithmeticException e) {
     LOG.warn("overflow when adding cardinalities: " + a + ", " + b);
     return Long.MAX_VALUE;
   }
 }
Esempio n. 2
0
 @Override
 public boolean noAddOverflow(long a, long b) {
   try {
     LongMath.checkedAdd(a, b);
     return true;
   } catch (ArithmeticException e) {
     return false;
   }
 }
Esempio n. 3
0
 public Fiat add(final Fiat value) {
   checkArgument(value.currencyCode.equals(currencyCode));
   return new Fiat(currencyCode, LongMath.checkedAdd(this.value, value.value));
 }
Esempio n. 4
0
 public Coin add(final Coin value) {
   return new Coin(LongMath.checkedAdd(this.value, value.value));
 }