How to resolve a Quantity instance for a Number and Unit

Open
#201 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Documentation
Clarity
Mostly clear
Activity status
Stale
Tech stack
java
Domain
api

Research direction

Start with the javax.measure.spi.ServiceProvider and QuantityFactory entry points named in the issue, then compare them with Indriya's Quantities.getQuantity(Number, Unit) implementation. Determine whether the standard API supports this without a runtime Quantity class; document the answer and any required API change or limitation.

Written by the indexing model from the issue text.

Description

deferred question

Hello, I am not finding how to resolve a Quantity<?> instance if I am starting with a Number and a Unit<?> instance, using only the javax.measure API. The trouble here is that I don't know the Quantity class at runtime, so I can't call javax.measure.spi.ServiceProvider.getQuantityFactory(Class<Q> quantity) to get the appropriate QuantityFactory on which I could call javax.measure.spi.QuantityFactory.create(Number value, Unit<Q> unit).

I don't know there is a very easy way using Indriya: tech.units.indriya.quantity.Quantities.getQuantity(Number value, Unit<Q> unit) but I am trying to understand how to achieve the same thing with only the javax.measure API. Could you point me in the right direction?

Dominant language
Java
Stars
195
Forks
41
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from unitsofmeasurement/unit-api

All issues in unitsofmeasurement/unit-api

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.