Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Guidelines and/or a system for subclassing/expanding an existing System of Units #202

Closed
fref opened this issue Aug 22, 2023 · 1 comment

Comments

@fref
Copy link

fref commented Aug 22, 2023

If I want to work with/add new units, then serialize values made of a combination of those units and the standard units, what should be be the standard way of doing this?

A cursory glance at UCUM/SI gives the impression that if I want to add new units, I have to create a new AbstractSystemOfUnits child, then redefine or reinject in it all the units of another system manually. No extension mechansim seems to exist.

It would be nice to have some sort of hierarchical structure, similar to the classloader mechanism, to allow one to work with the child system of units, passing the request upwards when a given unit is not found directly in the "managed" units of the child (e.g. when deserializing values)

@keilw
Copy link
Member

keilw commented Aug 22, 2023

You get that via ServiceProvider SPI. The SystemsOfUnitsService provides one or more SystemsOfUnits implementations.
It all uses the service loader mechanism.

There is no fallback to another system, you might have to go through various available service providers.
Feel free to create a an example for such mechanisms in uom-demos/console/systems, e.g. UCUM because that uses other systems, but the UCUM system is meant to be complete and consistent anyway, so such a fallback would not make as much sense there. Maybe for US or Imperial and SI, etc. I close this here, because it is not subject to the systems themselves, please create either that demo as a basis if you can, or also a feature request for the SPI in a future version. Could be related to unit-api#90

@keilw keilw closed this as completed Aug 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants