JSR 354 interoperability for obtaining numeric value from Quantity
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Anfängerfreundlichkeit
- 45/100
Rechercherichtung
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.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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.
- Vorherrschende Sprache
- Java
- Sterne
- 195
- Forks
- 41
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Entwicklungsumgebung
Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus unitsofmeasurement/unit-api
-
Typo in Docs unit-api/docs/apidocs/javax/measure /Quantity.htmlEvtl. vergeben @nightcityblade hat das vor 94 Tagen übernommen. Offen
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 88/100
unitsofmeasurement/unit-api#261 · 1 Kommentar ·
-
Units can have non-integer DimensionEvtl. vergeben @Dustin4444 hat das vor 561 Tagen übernommen. Offendeferred design
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 30/100
unitsofmeasurement/unit-api#256 · 5 Kommentare ·
-
Explore JDK Vector APIOffendeferred design enhancement jdk
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 20/100
unitsofmeasurement/unit-api#215 ·
-
deferred question
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 35/100
unitsofmeasurement/unit-api#201 · 4 Kommentare ·
-
Classpath DiscoveryOffendeferred enhancement jdk ready task
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 25/100
unitsofmeasurement/unit-api#90 · 1 Kommentar ·
Alle Issues in unitsofmeasurement/unit-api
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 64/100
-
enhancement
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
liquid-java/liquidjava#373 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
NationalSecurityAgency/ghidra#9748 ·
Maintainer antworten meist innerhalb von 1 Tag
-
enhancement
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 85/100
Maintainer antworten meist innerhalb von 1 Tag
-
spring-mcp-tools
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 85/100
explyt/spring-plugin#591 ·
Maintainer antworten meist innerhalb von 1 Tag