[JSR-354] Region API/SPI
- From: Anatole Tresch <atsticks@...>
- To: Jsr 354 JavaMoney Public Mailinglist <jcurrency_mail@...>
- Subject: [JSR-354] Region API/SPI
- Date: Mon, 15 Jul 2013 00:44:02 +0200
yet another topic is the *Regions *API. I wold like to do another proposal
to simplify/separate concerns:
Hereby the keypoints are:
- A Region is just an interface with
- a RegionType (as before)
- a textual code (required)
- an (optional) numeric ID
And yes, this is very similar to what we have in the area of currrencies.
- Similar to currencies (but without the regional relation) I can access
- Additionally I can access the (possibly) different RegionNode as
region forest, or access a RegionNode by its top level region
identifiers (type, code). The RegionNode similar to the previously
modeled Region, has a parent and children and allows for tree navigation.
This makes the API quite simply, e.g.
Region ger = Regions.get(RegionType.COUNTRY, "GER"); // Germany
RegionNode reg = Regions.getRegionNode(ger);
Collection<RegionNode> children = reg.getChildren();
RegionNode reg2 = Regions.get(RegionType.COUNTRY, "GER"); // Germany
RegionNode reg3 = Regions.get("WOLRD/EUROPE/COUNTRIES/ISO/GER");
// Germany by path
On the spi side this has some advantages:
- Spi implementation for region definition, region validity and region
tree structure can be easily separated.
- Access to regfions/region nodes is still simple.
- Region tree is highly adaptable and easy to extend.
So have a look at this and write down your feedback.
Have a good night (or morning...).
Java Lead Engineer, JSR Spec Lead
CH - 8620 Wetzikon
*Switzerland, Europe Zurich, GMT+1*
Phone +41-44 334 40 87
Mobile +41-76 344 62 79*