javamoney
  1. javamoney
  2. JAVAMONEY-25

Multi MonetaryAmount and CurrencyUnit Values

    Details

    • Type: New Feature New Feature
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Won't Fix
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Impl: RI
    • Labels:
      None

      Description

      Define a compound multi-valued monetary amount that consists of several amounts:

      • of the same currency, but with different semantics, e.g. for use cases in insurance calculations
      • of different currencies, e.g. for easily switching between currencies supported in web shop
      • a mix of the above.

      A compound value has the following properties:

      • it is immutable.
      • it does not offer arithemtics
      • it provides access to all its containing{{MonetaryAmount}} instances:
        • Map<String,MonetaryAmount> getAll()
        • Enumeration<String> getKeys();
        • MonetaryAmount getMonetaryAmount(String key)
        • boolean isMonetaryAmountDefined(String key)
      • It allows access to all different currencies contained:
        • Enumeration<CurrencyUnit> getContainedCurrencies()
      • it provides a CompoundMonetaryAmountFactory for creating compound values.
      • Since a compound amount is defined to be immutable, it can only be extended/adapted as follows:
        • CompoundMonetaryAmount add(String key, MonetaryAmount amount);
        • CompoundMonetaryAmount remove(String... key);
        • CompoundMonetaryAmountBuilder toBuilder() // and using the builder to create a new instance

        Activity

        atsticks created issue -
        atsticks made changes -
        Field Original Value New Value
        Description Define a compound multi-valued monetary amount that consists of several amounts:
        * of the same currency, but with different semantics, e.g. for use cases in insurance calculations
        * of different currencies, e.g. for easily switching between currencies supported in web shop
        * a mix of the above.

        A compound value has the following properties:
        * it is immutable.
        * it does not offer arithemtics
        * it provides access to all its containing{{MonetaryAmount}} instances:
        ** {{Map<String,MonetaryAmount> getAll()}}
        ** {{Enumeration<String> getKeys();}}
        ** {{MonetaryAmount getAmount(String key)}}
        ** {{boolean isAmountDefined(String key)}}
        * It allows access to all different currencies contained:
        ** {{Enumeration<CurrencyUnit> getContainedCurrencies()}}
        * it provides a {{CompoundAmountFactory}} for creating compound values.
        * Since a compound amount is defined to be immutable, it can only be extended/adapted as follows:
        ** {{CompoundMonetaryAmount add(String key, MonetaryAmount amount);}}
        ** {{CompoundMonetaryAmount remove(String... key);}}

        Define a compound multi-valued monetary amount that consists of several amounts:
        * of the same currency, but with different semantics, e.g. for use cases in insurance calculations
        * of different currencies, e.g. for easily switching between currencies supported in web shop
        * a mix of the above.

        A compound value has the following properties:
        * it is immutable.
        * it does not offer arithemtics
        * it provides access to all its containing{{MonetaryAmount}} instances:
        ** {{Map<String,MonetaryAmount> getAll()}}
        ** {{Enumeration<String> getKeys();}}
        ** {{MonetaryAmount getMonetaryAmount(String key)}}
        ** {{boolean isMonetaryAmountDefined(String key)}}
        * It allows access to all different currencies contained:
        ** {{Enumeration<CurrencyUnit> getContainedCurrencies()}}
        * it provides a {{CompoundMonetaryAmountFactory}} for creating compound values.
        * Since a compound amount is defined to be immutable, it can only be extended/adapted as follows:
        ** {{CompoundMonetaryAmount add(String key, MonetaryAmount amount);}}
        ** {{CompoundMonetaryAmount remove(String... key);}}
        ** {{CompoundMonetaryAmountBuilder toBuilder()}} // and using the builder to create a new instance
        Hide
        keilw added a comment -

        Sorry, but this seems a little to specific for most users.
        On that I can only agree with Stephen about the 80% of users. It is certainly valid, but shouldn't go into "core", probably more towards one of the EE-related modules or simply an extension.

        Show
        keilw added a comment - Sorry, but this seems a little to specific for most users. On that I can only agree with Stephen about the 80% of users. It is certainly valid, but shouldn't go into "core", probably more towards one of the EE-related modules or simply an extension.
        keilw made changes -
        Component/s Spec: extensions [ 14823 ]
        Component/s Spec: core [ 14820 ]
        Hide
        chrispheby added a comment -

        Is another use case an e-'wallet' concept for the above?

        Show
        chrispheby added a comment - Is another use case an e-'wallet' concept for the above?
        Hide
        atsticks added a comment -

        Currently only a CompoundItem and CompoundItemBuilder are defined in convert as interfaces. The effective value types are implemented within the RI only as of now. It can be useful to move these interfaces into the extensions module.
        Basically one of the most important use cases are pension calculations, where several input parameters are required and also the result of a pension calculation are multiple amounts, e.g. death capital, total capital, buy in option, risk investment strategy amounts etc.

        Show
        atsticks added a comment - Currently only a CompoundItem and CompoundItemBuilder are defined in convert as interfaces. The effective value types are implemented within the RI only as of now. It can be useful to move these interfaces into the extensions module. Basically one of the most important use cases are pension calculations, where several input parameters are required and also the result of a pension calculation are multiple amounts, e.g. death capital, total capital, buy in option, risk investment strategy amounts etc.
        Hide
        keilw added a comment -

        Both CompoundItem and CompoundItemBuilder are generic in convert, so they seem more like "specialized Collection API" elements than part of "Conversion API", I agree they might go to "ext", which doesn't prevent certain implementations from using those interfaces. Whether or not that'll be the RI and for which target platform, we shall see.

        Show
        keilw added a comment - Both CompoundItem and CompoundItemBuilder are generic in convert, so they seem more like "specialized Collection API" elements than part of "Conversion API", I agree they might go to "ext", which doesn't prevent certain implementations from using those interfaces. Whether or not that'll be the RI and for which target platform, we shall see.
        atsticks made changes -
        Comment [ kjh ]
        atsticks made changes -
        Summary Multi Currency Monetary Value Multi MonetaryAmount Value
        atsticks made changes -
        Summary Multi MonetaryAmount Value Multi MonetaryAmount and CurrencyUnit Values
        atsticks made changes -
        Fix Version/s 1.0-b01 [ 16318 ]
        atsticks made changes -
        Component/s Spec: Specification [ 14828 ]
        atsticks made changes -
        Fix Version/s 0.3 [ 16322 ]
        Fix Version/s 1.0-b01 [ 16318 ]
        keilw made changes -
        Fix Version/s 0.5 [ 16430 ]
        Fix Version/s 0.3 [ 16322 ]
        Priority Major [ 3 ] Minor [ 4 ]
        atsticks made changes -
        Fix Version/s 0.5 [ 16430 ]
        Component/s Impl: Java Money Extras [ 15070 ]
        Component/s API: Provided Extensions [ 14823 ]
        keilw made changes -
        Component/s Impl: RI [ 14824 ]
        Component/s Impl: Java Money Extras [ 15070 ]
        keilw made changes -
        Fix Version/s 0.9 [ 16866 ]
        Hide
        atsticks added a comment -

        This Feature has not shown to be useful as part of API/RI. May be something can be added to lib, but also here there is no real Advantage to just using a map of <x, MonetaryAmount>.

        Show
        atsticks added a comment - This Feature has not shown to be useful as part of API/RI. May be something can be added to lib, but also here there is no real Advantage to just using a map of <x, MonetaryAmount>.
        atsticks made changes -
        Status Open [ 1 ] Closed [ 6 ]
        Fix Version/s 0.9 [ 16866 ]
        Resolution Won't Fix [ 2 ]

          People

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

            Dates

            • Created:
              Updated:
              Resolved: