Le 09/03/2018 à 17:05, César Martínez Izquierdo a écrit :
I was just considering our own use case, in which different 3rd party libraries can be integrated in our product, each using different implementations. If we receive a Unit from one of those libs, it is quite limiting if we can't consider "safe" to provide such instance to one of the other libraries. I guess in this case we would need to build a kind of bridge to convert instances from one implementation to a different one.
We could emit recommendation to implementors, along the lines discussed in previous email (formatting then parsing standard unit symbols).
It would be great if each library using the API would create the Unit instances only using generic methods such as: ServiceProvider provider = ServiceProvider.current(); UnitFormatService formatService = provider.getUnitFormatService(); UnitFormat defaultFormat = formatService.getUnitFormat(); METRE = (Unit<Length>) defaultFormat.parse("m"); In this way, we could use setCurrent to choose an implementation in runtime for all those 3rd party libraries.
This is different than the previous proposal, to encourage implementations to accept "foreigner" units. In this second approach, a single implementation would be used.
A possible issue is that some libraries may have reasons for using their own unit implementation. I can not tell for other libraries, but taking Apache SIS as an example, some reasons are:
For safety, SIS uses its own Unit implementation
without interfering with ServiceProvider.current(), so
users can set their own implementation for other libraries.
Martin
--
You received this message because you are subscribed to the Google Groups "Units Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to units-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.