User tried to use this method with
Map<String,Long> prices = ...
long price = Decimal64Util.parse("229");
prices.put("AAPL", price);
boolean samePrice = (Decimal64Util.equals(price, prices.get("AAPL")); // returns FALSE (where TRUE is expected)
At minimum we should update javadoc. But I would rather support Long (boxed version of long).
Alternatively: Any specific reason the method signature takes java.lang.Object instead of Decimal64 as second argument.
/**
* Returns {@code true} if two {@code DFP} values represent the same arithmetical value.
* <p>
* We consider that all possible encodings of {@link #POSITIVE_INFINITY} are equal,
* all possible encodings of {@link #NEGATIVE_INFINITY} are equal,
* all possible encodings of NaN and SNaN are equal,
* all invalid encodings of finite values equal {@link #ZERO}
*
* @param a the first 64-bit DFP value.
* @param b the second 64-bit DFP value.
* @return {@code true} if two decimal values represent the same arithmetical value.
*/
public static boolean equals(@Decimal final long a, final Object b) {
return (b == null && NULL == a)
|| (b instanceof Decimal64 && equals(a, ((Decimal64) b).value));
}
User tried to use this method with
At minimum we should update javadoc. But I would rather support Long (boxed version of long).
Alternatively: Any specific reason the method signature takes java.lang.Object instead of Decimal64 as second argument.