Exemplo 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;
   }
 }
Exemplo n.º 2
0
 @Override
 public boolean noAddOverflow(long a, long b) {
   try {
     LongMath.checkedAdd(a, b);
     return true;
   } catch (ArithmeticException e) {
     return false;
   }
 }
Exemplo n.º 3
0
 public Fiat add(final Fiat value) {
   checkArgument(value.currencyCode.equals(currencyCode));
   return new Fiat(currencyCode, LongMath.checkedAdd(this.value, value.value));
 }
Exemplo n.º 4
0
 public Coin add(final Coin value) {
   return new Coin(LongMath.checkedAdd(this.value, value.value));
 }