JSR 354 interoperability for obtaining numeric value from Quantity
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Accessibilité débutants
- 45/100
Piste de recherche
Start by comparing the JSR 354 MonetaryAmount and JSR 363 Quantity accessors, especially getNumber(), getValue(), and the existing NumberSupplier interface. Evaluate whether a shared NumericValueSupplier or NumericComponentSupplier fits both APIs without obscuring domain meaning. Done means the compatibility and naming implications are resolved into an agreed API design.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Both JSR 354 and JSR 363 define an API with a main class/interface whose role is represent a numeric quantity with some kind of additional unit and other metadata. It would be useful for programs that need to deal with both quantities and currencies to be able to deal with both of these main value classes in a generic way in some use cases.
In my use case, a precious metals business process automation webapp, has a notion of both monetary and material accounts. It has a parameterised base class AbstractAccountLedger<B> with method public B getBalance(), with concrete subclasses MonetaryAccountLedger<MonetaryAmount> and MetalAccountLedger<Quantity<Mass>>.
However, since MonetaryAmount and Quantity defines two different accessors for obtaining the numeric component of each (public Number getNumber() and public Number getValue(), respectively), the application needs duplicate codepaths to handle each in a generic way. For exmaple, when asserting pre- and post-conditions after performing account transaction operations in the AccountsService implementation, when streaming over collections that contain instances of both account types, and when logging numeric values.
It would be extremely convenient in these cases if both JSR APIs supported a common functional interface for accessing the numeric value, so that the parameterised base class could set that as common lower bound for its type parameter B, and hence allowing the currently required multiple near-duplicate codepaths to be collapsed into single generic codepaths.
While the JDK has defined Supplier<T> since v8, that functional interface's get() method is perhaps too generic for the domain models. JSR 354 currently defines a NumberSupplier functional interface with Number getNumber(), inspired perhaps by the JDK's Supplier<T>, that is also somewhat generic - what part of the domain model does that really return, just by looking at the method name?
I would instead suggest a common functional interface NumericValueSupplier or perhaps NumericComponentSupplier is defined with single method Number getNumericValue() as a shared joint interface to address this issue.
- Langage dominant
- Java
- Étoiles
- 195
- Forks
- 41
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Préparer son environnement
Ce projet ne fournit ni conteneur de développement, ni Dockerfile, ni guide de contribution : l'installation est à votre charge. Commencez par son README, et consultez notre guide de la première contribution pour les étapes générales.
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de unitsofmeasurement/unit-api
-
Typo in Docs unit-api/docs/apidocs/javax/measure /Quantity.htmlPeut-être pris @nightcityblade l’a pris il y a 112 jours. Ouverte
Difficulté 1/5 Moins d'une heure Accessibilité débutants 88/100
unitsofmeasurement/unit-api#261 · 1 commentaire ·
-
Units can have non-integer DimensionPeut-être pris @Dustin4444 l’a pris il y a 578 jours. Ouvertedeferred design
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 30/100
unitsofmeasurement/unit-api#256 · 5 commentaires ·
-
Explore JDK Vector APIOuvertedeferred design enhancement jdk
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 20/100
unitsofmeasurement/unit-api#215 ·
-
deferred question
Difficulté 4/5 3-5 jours Accessibilité débutants 35/100
unitsofmeasurement/unit-api#201 · 4 commentaires ·
-
Classpath DiscoveryOuvertedeferred enhancement jdk ready task
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 25/100
unitsofmeasurement/unit-api#90 · 1 commentaire ·
Toutes les issues de unitsofmeasurement/unit-api
Issues similaires
-
staticAssetsPath follows symlinks outside the directory on WindowsPeut-être pris @ybelMekk l’a pris aujourd’hui. Ouvertebug security findings
Difficulté 2/5 1-3 heures Accessibilité débutants 84/100
navikt/mock-oauth2-server#1132 ·
Les mainteneurs répondent en général sous 1 jour
-
agent:working follow-up
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
Sanne/incus-spawn#1683 · 2 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
checkstyle/checkstyle#22210 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 67/100
google/error-prone#6239 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
[Failing Test]: BigqueryClient.queryUnflattened fails BigQuery ITs on a transient 503Peut-être pris @mxtymoshyk l’a pris aujourd’hui. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 77/100
Les mainteneurs répondent en général sous 1 jour