Adopt JSR 354

Download Adopt JSR 354

Post on 31-Oct-2014

233 views

Category:

Technology

3 download

Embed Size (px)

DESCRIPTION

Presentation that shows a brief overview about the JSR and gives hint on how you can contribute to the API, TCK or OSS library.

TRANSCRIPT

<ul><li> 1. Go for the Money Adopt JSR 354 Slideshare 2014 March 2014 Go for the money Adopt JSR 354 - http://java.net/projects/javamoney </li> <li> 2. Go for the money - JSR 354 - http://java.net/projects/javamoney March 2014 Bio Anatole Tresch Consultant, Coach Credit Suisse Technical Coordinator &amp; Architect Specification Lead JSR 354 Regular Conference Speaker Driving Java EE Config Twitter/Google+: @atsticks atsticks@java.net anatole.tresch@credit-suisse.com Java Config Discussion https://groups.google.com/forum/#!forum/java-config Java Config Blog: http://javaeeconfig.blogspot.ch Zurich Java Community (Google Community) Zurich Hackergarten 2 </li> <li> 3. Go for the money - JSR 354 - http://java.net/projects/javamoney March 2014 Agenda 3 Overview Setup Adoption Areas API Challenge: Moneymachine Helping out with the TCK Adding functonalities to the RI, e.g. Cash Roundings Stabilizing JavaMoney Library Other ? </li> <li> 4. Go for the money - JSR 354 - http://java.net/projects/javamoney March 2014 Overview 4 </li> <li> 5. Go for the money - JSR 354 - http://java.net/projects/javamoney March 2014 Money Machine 5 </li> <li> 6. Go for the money - JSR 354 - http://java.net/projects/javamoney March 2014 Overview of JSR 354 and Javamoney API (javax.money): CurrencyUnit, MonetaryAmount, MonetaryOperator, MonetaryQuery, CurrencyConversion, ExchangeRate, MonetaryAmountFormat, MonetaryException; MonetaryCurrencies, MonetaryAmounts, MonetaryRoundings, MonetaryConversions, MonetaryFormats RI (org.javamoney.moneta): BuildableCurrencyUnit, Money, FastMoney, MonetaryFunctions TCK (org.javamoney.tck): Javamoney (GitHub OSS project): org.javamoney format (extended API) currencies (mapping) Regions Validity calc 6 </li> <li> 7. Go for the money - JSR 354 - http://java.net/projects/javamoney March 2014 Currencies and Monetary Amounts javax.money 7 </li> <li> 8. Go for the money - JSR 354 - http://java.net/projects/javamoney March 2014 Currencies (continued) API 8 Allow currencies with arbitrary other currency codes Register additional Currency Units using an flexible SPI Fluent API using a Builder (RI only) Historic Validity of currencies related to regions/countries and vice versa (not part of JSR, but javamoney OSS project) public interface CurrencyUnit{ public String getCurrencyCode(); public int getNumericCode(); public int getDefaultFractionDigits(); } public final class MonetaryCurrencies{ public CurrencyUnit getCurrency(String currencyCode); public CurrencyUnit getCurrency(Locale locale); public boolean isCurrencyAvailable(String currencyCode); public boolean isCurrencyAvailable(String locale); } </li> <li> 9. Go for the money - JSR 354 - http://java.net/projects/javamoney March 2014 Currencies (continued) API Samples CurrencyUnit currency1 = MonetaryCurrencies.getCurrency("USD"); CurrencyUnit currency2 = MonetaryCurrencies.getCurrency( Locale.GERMANY); CurrencyUnit bitcoin = new BuildableCurrencyUnit.Builder("BTC") .setNumericCode(123456) .setDefaultFractionDigits(8) .create(); 9 Access a CurrencyUnit Build a CurrencyUnit (RI only) Register a CurrencyUnit CurrencyUnit bitcoin = .create(true); </li> <li> 10. Go for the money - JSR 354 - http://java.net/projects/javamoney March 2014 Monetary Amounts General Aspects 10 Amount = Currency + Numeric Value + Capabilities Arithmetic Functions, Comparison Fluent API </li> <li> 11. Go for the money - JSR 354 - http://java.net/projects/javamoney March 2014 Monetary Amounts (continued) Key Decisions 11 Support Several Numeric Representations (instead of one single fixed value type) Use functional design for extendible functionality (MonetaryOperator, MonetaryQuery) Define Implementation Recommendations Rounding should to be modelled as separate concern (a MonetaryOperator) Ensure Interoperability by the MonetaryAmount interface Precision/scale capabilities should be inherited to its operational results. </li> <li> 12. Go for the money - JSR 354 - http://java.net/projects/javamoney March 2014 Monetary Amounts (continued) The API public interface MonetaryAmount{ public CurrencyUnit getCurrency(); public NumberValue getNumber(); public MonetaryContext getMonetaryContext(); public MonetaryAmount with(MonetaryOperator operator); public R query(MonetaryQuery query); public MonetaryAmountFactory</li></ul>