Skip to content

UtilityAndArithmetic

Business Purpose

Provides static utility methods for common monetary operations such as comparison, aggregation, and safe arithmetic with null handling. [AI Inference] These complement the instance methods on monetary objects for convenience and safety.

Current Behaviors

Technical Implementation

  • MoneyUtils MoneyUtils.java:31 has no design pattern; it's a set of static methods.
  • Null parameters cause NullPointerException via checkNotNull MoneyUtils.java:31.
  • Currency mismatches in add and subtract throw CurrencyMismatchException (implied from methods).
  • Ser Ser.java:72 implements Externalizable and is marked IMMUTABLE_VALUE_OBJECT.
  • Ser methods are @Override (Ser.java:72,112) and handle BigMoney and CurrencyUnit serialization.

Definition of Done

  • MoneyUtils.max(Money.of(USD, 10), Money.of(USD, 20)) returns the Money with 20.
  • MoneyUtils.add(Money.of(EUR, 5), Money.of(EUR, 3)) returns a Money with EUR and amount 8.
  • Passing a null MoneyProvider to isZero throws NullPointerException.
  • Attempting add with different currencies throws CurrencyMismatchException.
  • Serializing a BigMoney and deserializing results in an equal object.
  • MoneyUtils.isNegative(BigMoney.of(GBP, -1)) returns true.