@Test public void shouldSubstractFailOnEmptyOperand() { final Object[][] parameters = new Object[][] { {Aer.EMPTY, Aer.ONE}, {Aer.ONE, Aer.EMPTY} }; for (final Object[] parameter : parameters) { final Aer left = (Aer) parameter[0]; final Aer right = (Aer) parameter[1]; try { left.subtract(right); fail(); } catch (AssertionError e) { } } }
public Aer subtract(final Aer other) { assertNotNull(other, "Other is null"); assertNotEquals(Aer.EMPTY, this, "Cannot subtract to Aer.EMPTY"); assertNotEquals(Aer.EMPTY, other, "Cannot add with Aer.EMPTY"); final BigInteger subtracted = this.value.subtract(other.value); return new Aer(subtracted.compareTo(BigInteger.ZERO) < 0 ? BigInteger.ZERO : subtracted); }
Aer implements Comparable<Aer> { public Aer subtract(final Aer other) { assertNotNull(other, "Other is null"); assertNotEquals(Aer.EMPTY, this, "Cannot subtract to Aer.EMPTY"); assertNotEquals(Aer.EMPTY, other, "Cannot add with Aer.EMPTY"); final BigInteger subtracted = this.value.subtract(other.value); return new Aer(subtracted.compareTo(BigInteger.ZERO) < 0 ? BigInteger.ZERO : subtracted); } }
Aer implements Comparable<Aer> { public Aer subtract(final Aer other) { assertNotNull(other, "Other is null"); assertNotEquals(Aer.EMPTY, this, "Cannot subtract to Aer.EMPTY"); assertNotEquals(Aer.EMPTY, other, "Cannot add with Aer.EMPTY"); final BigInteger subtracted = this.value.subtract(other.value); return new Aer(subtracted.compareTo(BigInteger.ZERO) < 0 ? BigInteger.ZERO : subtracted); } Aer(final String amount);  Aer(final String amount, final Unit unit);  Aer(final BigInteger amount); protected  Aer(); }
Aer implements Comparable<Aer> { public Aer subtract(final Aer other) { assertNotNull(other, "Other is null"); assertNotEquals(Aer.EMPTY, this, "Cannot subtract to Aer.EMPTY"); assertNotEquals(Aer.EMPTY, other, "Cannot add with Aer.EMPTY"); final BigInteger subtracted = this.value.subtract(other.value); return new Aer(subtracted.compareTo(BigInteger.ZERO) < 0 ? BigInteger.ZERO : subtracted); } Aer(final String amount);  Aer(final String amount, final Unit unit);  Aer(final BigInteger amount); protected  Aer(); static Aer of(final String amount); static Aer of(final String amount, final Unit unit); static Aer of(final BigInteger amount); Aer add(final Aer other); Aer subtract(final Aer other); @Override int compareTo(final Aer other); @Override String toString(); String toString(final Unit unit); }
Aer implements Comparable<Aer> { public Aer subtract(final Aer other) { assertNotNull(other, "Other is null"); assertNotEquals(Aer.EMPTY, this, "Cannot subtract to Aer.EMPTY"); assertNotEquals(Aer.EMPTY, other, "Cannot add with Aer.EMPTY"); final BigInteger subtracted = this.value.subtract(other.value); return new Aer(subtracted.compareTo(BigInteger.ZERO) < 0 ? BigInteger.ZERO : subtracted); } Aer(final String amount);  Aer(final String amount, final Unit unit);  Aer(final BigInteger amount); protected  Aer(); static Aer of(final String amount); static Aer of(final String amount, final Unit unit); static Aer of(final BigInteger amount); Aer add(final Aer other); Aer subtract(final Aer other); @Override int compareTo(final Aer other); @Override String toString(); String toString(final Unit unit); static final String EMPTY_STRING; static final Aer EMPTY; static final Aer ZERO; static final Aer ONE; static final Aer GIGA_ONE; static final Aer AERGO_ONE; }