use of tech.units.indriya.AbstractUnit in project indriya by unitsofmeasurement.
the class AbsUnitTest method testCompound2.
@SuppressWarnings("unchecked")
@Test
public void testCompound2() {
@SuppressWarnings("rawtypes") final AbstractUnit hourMin = (AbstractUnit) ((AbstractUnit) HOUR).compound(MINUTE);
assertEquals("h:min:s", hourMin.compound(SECOND).toString());
}
use of tech.units.indriya.AbstractUnit in project indriya by unitsofmeasurement.
the class ProductUnit method getSystemConverter.
@Override
public UnitConverter getSystemConverter() {
UnitConverter converter = AbstractConverter.IDENTITY;
for (Element e : elements) {
if (e.unit instanceof AbstractUnit) {
UnitConverter cvtr = ((AbstractUnit) e.unit).getSystemConverter();
if (!(cvtr.isLinear()))
throw new UnsupportedOperationException(e.unit + " is non-linear, cannot convert");
if (e.root != 1)
throw new UnsupportedOperationException(e.unit + " holds a base unit with fractional exponent");
int pow = e.pow;
if (pow < 0) {
// Negative power.
pow = -pow;
cvtr = cvtr.inverse();
}
for (int j = 0; j < pow; j++) {
converter = converter.concatenate(cvtr);
}
}
}
return converter;
}
Aggregations