Closed keilw closed 5 years ago
If it's not too vague we could also use java.util.function.Supplier<Number>
instead.
@andi-huber What do you think, it's not just used by Tamil or other exotic prefixes, think of the "Quarterpounder".
Actually the least invasive approach seems like adding a numeric method getValue()
instead of getBase()
(nothing restricts the base from being a floating point number, BigDecimal
also has a pow()
method) and allow MultiplyConverter
to decide whether to create a RationalConverter
, PowerofIntConverter
(which probably better be called IntPowerConverter
now, we have drastically reduced cohesion here, so we can rename it) So we don't have to fumble with a type or other categorization. If exponent is 1, it'll have no effect and the number can be treated like rational value.
Would it be an option to have a numeric method like
getValue()
orgetFactor()
inPrefix
, too?
This would make sense from my perspective, yes. Use Number
to replace double
, if possible or otherwise at least allow for a Prefix to be defined by a 'scaling factor' of type Number
as an alternative to double
.
Ok, will have a look at it tonight or tomorrow after our talk. Thanks
@keilw I guess your last comment implies you will be working on it.
It's mostly done already ;-)
When checking out other international prefixes, I came across fractions, that do not simply deal with an exponent like https://en.wikipedia.org/wiki/Tamil_units_of_measurement#Fractions For example
1/2= 0.5 – அரை – arai
which would be aRationalNumber.of(1, 2)
using Indriya.UCAR Units has this Prefix with a conversion factor that is a
double
. Would it be an option to have a numeric method likegetValue()
orgetFactor()
inPrefix
, too?