Examples (JAVAMONEY-8)

[JAVAMONEY-40] Bitcoin Examples Created: 18/Apr/13  Updated: 10/Nov/13  Resolved: 10/Nov/13

Status: Closed
Project: javamoney
Component/s: Misc: JCP Administration
Affects Version/s: None
Fix Version/s: 0.7

Type: Sub-task Priority: Major
Reporter: keilw Assignee: keilw
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: 0 minutes
Time Spent: Not Specified
Original Estimate: 0 minutes

Tags: currency, multi-curency

 Comments   
Comment by keilw [ 03/Sep/13 ]

MtGox available via TrakStok (incorporating it into RI or Extras pending)
Consider similar support for BitStamp, BTC-E, CampBX,...

Comment by keilw [ 10/Nov/13 ]

Closing this, the issue tracker for these is now at GitHub





[JAVAMONEY-13] Abstraction for Currencies Created: 31/Jan/13  Updated: 08/Aug/13  Resolved: 26/Apr/13

Status: Closed
Project: javamoney
Component/s: API
Affects Version/s: 0.3
Fix Version/s: 0.4-EDR1

Type: New Feature Priority: Critical
Reporter: atsticks Assignee: atsticks
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: 0 minutes
Time Spent: Not Specified
Original Estimate: 0 minutes

Tags: Currency, CurrencyUnit, api, multi-curency, time_handling

 Description   

Provide an interface and a value type for a CurrencyUnit, which provides the following functionality:

  • the CurrencyUnit interface modelled does not define any methods for changing the internal state.
  • the value type must be final and immutable, and implement the CurrencyUnit interface.
  • CurrencyUnit may have different namespaces, e.g. 'ISO-4217' (default), but also arbitrary others are supported.
  • the namespace of a CurrencyUnit can be accessed by a corresponding method String getNamespace().
  • a CurrencyUnit must have a unique literal currency code unique within the namespace, accessible by a method String getCurrencyCode().
  • a CurrencyUnit provides the basic non localized methods similar to java.util.Currency for maximal backwards compatibility:
    • int getNumericCode() Gets a numeric currency code. Hereby -1 is returned if no numeric code is available for an instance.
    • int getDefaultFractionDigits(), Gets the number of fractional digits typically used by a currency. -1 is returned if no such value is available for an instance
  • a CurrencyUnit has a time period defined, when it is valid. This is modelled by Long getValidFrom(); and Long getValidUntil();.
    • If no feasible values can be returned, or the currency unit is still valid in the current context, null is returned for the time period methods.
    • the implementation of CurrencyUnit by java.util.Currency should always return null for both methods as a default.
    • SPI implementation may create additional instances of CurrencyUnit also for the ISO-4217 namespace, that reflect the currency duration as defined also by ISO.
  • A CurrencyUnit has a boolean flag if it has a legal tender.
  • Finally a CurrencyUnit can be a real or a virtual currency, modelled by the boolean isVirtual() method.
  • a Currencynit extends AttributeProvider, which allows to provide additional arbitrary attributes. This is required since complex use cases, such as not clearly defined ISO codes and legal tenders may require passing additional information, that can not be fully covered by this JSR.
  • The implementations of CurrencyUnit must implement Comparable<CurrencyUnit>, whereas the interface does not define this requirements due to decoupling aspects.

Access
Instances of CurrencyUnit can be obtained

  • by using the CurrencyProvider available on the Monetary singleton. This allows to support more complex use cases, e.g. classification based access, historic currencies and alternate namespaces.
  • by using the static factory method on java.util.Currency instance (the JDK class must, of course, implement CurrencyUnit.





[JAVAMONEY-2] Make CurrencyUnit or adequate replacement an Interface Created: 01/Aug/12  Updated: 05/Feb/13  Due: 01/Dec/12  Resolved: 01/Dec/12

Status: Closed
Project: javamoney
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major
Reporter: keilw Assignee: keilw
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: 0 minutes
Time Spent: Not Specified
Original Estimate: 0 minutes

Tags: design, multi-curency

 Description   

As one of the main goals of the JSR is to support Custom Currencies, the straw man draft of CurrencyUnit based on JodaMoney will not work for it.

In fact, JSR 310 showed something like a "pattern" by introducing an interface PeriodUnit, then implemented by types such as LocalPeriodUnit.

Hence, CurrencyUnit (or another name if anybody has a better one) should be an interface, and (just an example) "LocalCurrencyUnit" or similar be implementing classes. Whether or not an enum would work for some implementations is probably worth exploring.

If enums won't work, then either the getInstance(), the of() or a different factory.
Java generally has valueOf(). It seems, of() is an attempt of a shorter version.
None of the common JVM languages seem to use that, Fantom has make() as constructor and from*() especially fromString(), but no of*() either.

-> Harmonize across API, where concrete Money types have similar factory methods.



 Comments   
Comment by keilw [ 01/Dec/12 ]

As of new repository CurrencyUnit was turned into an interface.
To be implemented by java.util.Currency in a matching version of OpenJDK or any equivalent currency type in other platforms, e.g. CLDC 8.





Generated at Mon Feb 20 17:48:30 UTC 2017 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.