jsr354-api icon indicating copy to clipboard operation
jsr354-api copied to clipboard

Convenience comparison function javadoc doesn't match implementation

Open ayush-finix opened this issue 1 year ago • 0 comments

Ex.

 /**
     * Compares two instances of {@link MonetaryAmount}, hereby ignoring non significant trailing
     * zeroes and different numeric capabilities.
     *
     * @param amount the {@link MonetaryAmount} to be compared with this instance.
     * @return {@code true} if {@code amount < this}.
     * @throws MonetaryException if the amount's currency is not equal to the currency of this instance.
     */
    boolean isLessThan(MonetaryAmount amount);

The java doc says that it returns true if amount < this, but every implementation (and a personal reading of this.isLessThan(amount) seems like it should) returns true if this < amount.

Ex with the reference moneta implementation

System.out.println(Money.of(BigDecimal.ONE, Monetary.getCurrency("USD"))
        .isLessThan(Money.of(BigDecimal.TEN, Monetary.getCurrency("USD"))));
true

ayush-finix avatar Jun 18 '24 06:06 ayush-finix