Details

    • Type: New Feature New Feature
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 0.8
    • Component/s: API
    • Labels:
      None
    • Environment:

      SE

      Description

      Model an interface MonetaryAmount and an according value type as follows:

      • the interface MonetaryAmount is designed as immutable, the implementation classes must be final and immutable.
      • a MonetaryAmount has a CurrencyUnit attached, each amount instance must have a CurrencyUnit.
      • a MonetaryAmount has a numeric value, which may is NOT exposed.
      • For interoperability MonetaryAmount provides converters to several types similar as defined on java.lang.Number.
      • For additional interoperability the MonetaryAmount defines a method <T> T asType<Class<T>) which allows to extract arbitrary representation types.
        • in a SE environment, it is required that
          • all number types extending java.lang.Number must be supported.
          • java.math.BigDecimal and java.math.BigInteger must be also supported.
          • when passing java.lang.Number.class BigDecimal is returned as result type.
        • in other environments this should be similar. If not possible, alternate types are allowed.
      • MonetaryAmount also provides basic arithmetic functions similar to java.math.BigDecimal. Extended functionality must be modelled using the Java Money extension SPI.
      • the methods String toPlainString() and String toEngineeringString() are supported similarly as in java.math.BigDecimal, whereas in this case the CurrencyUnit is prepended, e.g. ISO-4217:CHF 1234.35
      • Additional arithmetic operations not defined on MonetaryAmount can be applied by passing an AmountAdjuster instance to MonetaryAmount with(AmountAdjuster...).
      • Finally a MonetaryAmount with a different numeric value, but the same currency can be created by calling MonetaryAmount.width(java.lang.Number).

      Access

      • MonetaryAmount instances can be created by calling static factory methods on the value type classes directly, e.g.
        • Money m1 = Money.of(1.456,"CHF")
        • Money m2 = Money.of(-234456,Currency.get("USD")

        Activity

        There are no comments yet on this issue.

          People

          • Assignee:
            keilw
            Reporter:
            atsticks
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: