Class Money

java.lang.Object
org.episteme.social.economics.money.Money
All Implemented Interfaces:
Serializable, Quantity<Money>

public class Money extends Object implements Quantity<Money>, Serializable
Represents a quantity of money with currency. Implements Quantity<Money> to allow integration with the measurement system.
Since:
1.0
Author:
Silvere Martin-Michiellot, Gemini AI (Google DeepMind)
See Also:
  • Field Details

    • DIMENSION

      public static final Dimension DIMENSION
    • BASE_UNIT

      public static final Unit<Money> BASE_UNIT
  • Constructor Details

    • Money

      public Money(Real amount, Currency currency)
    • Money

      public Money(Real amount, String currencyCode)
  • Method Details

    • getValue

      public Real getValue()
      Description copied from interface: Quantity
      Returns the numerical value of this quantity in its current unit.
      Specified by:
      getValue in interface Quantity<Money>
      Returns:
      the quantity value
    • getUnit

      public Unit<Money> getUnit()
      Description copied from interface: Quantity
      Returns the unit of measurement for this quantity.
      Specified by:
      getUnit in interface Quantity<Money>
      Returns:
      the unit
    • to

      public Money to(Unit<Money> targetUnit)
      Description copied from interface: Quantity
      Converts this quantity to the specified unit.

      Returns a new quantity with the same physical magnitude but expressed in the target unit.

      Specified by:
      to in interface Quantity<Money>
      Parameters:
      targetUnit - the unit to convert to
      Returns:
      a new quantity in the target unit
    • add

      public Money add(Quantity<Money> other)
      Description copied from interface: Quantity
      Adds another quantity to this one.

      If the units differ, the other quantity is converted to this quantity's unit before addition.

      Specified by:
      add in interface Quantity<Money>
      Parameters:
      other - the quantity to add
      Returns:
      a new quantity representing the sum
    • subtract

      public Money subtract(Quantity<Money> other)
      Description copied from interface: Quantity
      Subtracts another quantity from this one.

      If the units differ, the other quantity is converted to this quantity's unit before subtraction.

      Specified by:
      subtract in interface Quantity<Money>
      Parameters:
      other - the quantity to subtract
      Returns:
      a new quantity representing the difference
    • add

      public Money add(Money other)
    • subtract

      public Money subtract(Money other)
    • multiply

      public Money multiply(Real scalar)
      Description copied from interface: Quantity
      Multiplies this quantity by a scalar value.
      Specified by:
      multiply in interface Quantity<Money>
      Parameters:
      scalar - the scalar multiplier
      Returns:
      a new quantity scaled by the given factor
    • multiply

      public Money multiply(double scalar)
      Description copied from interface: Quantity
      Multiplies this quantity by a scalar value.
      Specified by:
      multiply in interface Quantity<Money>
      Parameters:
      scalar - the scalar multiplier
      Returns:
      a new quantity scaled by the given factor
    • multiply

      public <R extends Quantity<R>> Quantity<?> multiply(Quantity<R> other)
      Description copied from interface: Quantity
      Multiplies this quantity by another quantity.

      The result's unit is the product of the two units. For example, multiplying Length by Length gives Area.

      Specified by:
      multiply in interface Quantity<Money>
      Type Parameters:
      R - the other quantity type
      Parameters:
      other - the quantity to multiply by
      Returns:
      a new quantity representing the product
    • divide

      public Money divide(Real scalar)
      Description copied from interface: Quantity
      Divides this quantity by a scalar value.
      Specified by:
      divide in interface Quantity<Money>
      Parameters:
      scalar - the scalar divisor
      Returns:
      a new quantity divided by the given factor
    • divide

      public Money divide(double scalar)
      Description copied from interface: Quantity
      Divides this quantity by a scalar value.
      Specified by:
      divide in interface Quantity<Money>
      Parameters:
      scalar - the scalar divisor
      Returns:
      a new quantity divided by the given factor
    • divide

      public <R extends Quantity<R>> Quantity<?> divide(Quantity<R> other)
      Description copied from interface: Quantity
      Divides this quantity by another quantity.

      The result's unit is the quotient of the two units. For example, dividing Length by Time gives Velocity.

      Specified by:
      divide in interface Quantity<Money>
      Type Parameters:
      R - the other quantity type
      Parameters:
      other - the quantity to divide by
      Returns:
      a new quantity representing the quotient
    • abs

      public Money abs()
      Description copied from interface: Quantity
      Returns the absolute value of this quantity.
      Specified by:
      abs in interface Quantity<Money>
      Returns:
      a new quantity with absolute value
    • negate

      public Money negate()
      Description copied from interface: Quantity
      Returns the negation of this quantity.
      Specified by:
      negate in interface Quantity<Money>
      Returns:
      a new quantity with negated value
    • compareTo

      public int compareTo(Quantity<Money> other)
      Description copied from interface: Quantity
      Compares this quantity with another for order. Both quantities are compared in this quantity's unit.
      Specified by:
      compareTo in interface Quantity<Money>
      Parameters:
      other - the quantity to compare with
      Returns:
      negative if less, zero if equal, positive if greater
    • equals

      public boolean equals(Quantity<Money> other, Real tolerance)
      Description copied from interface: Quantity
      Checks if this quantity equals another within tolerance.
      Specified by:
      equals in interface Quantity<Money>
      Parameters:
      other - the quantity to compare with
      tolerance - the acceptable difference
      Returns:
      true if quantities are equal within tolerance
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • pow

      public Quantity<?> pow(int exponent)
      Description copied from interface: Quantity
      Returns this quantity raised to the specified exponent.
      Specified by:
      pow in interface Quantity<Money>
      Parameters:
      exponent - the exponent
      Returns:
      this quantity raised to the exponent
    • sqrt

      public Quantity<?> sqrt()
      Description copied from interface: Quantity
      Returns the square root of this quantity.
      Specified by:
      sqrt in interface Quantity<Money>
      Returns:
      the square root of this quantity
    • getAmount

      public Real getAmount()
    • getCurrency

      public Currency getCurrency()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • valueOf

      public static Money valueOf(Real amount, Currency currency)
    • valueOf

      public static Money valueOf(double amount, Currency currency)
    • usd

      public static Money usd(Real amount)
    • usd

      public static Money usd(double amount)
    • eur

      public static Money eur(Real amount)
    • eur

      public static Money eur(double amount)