use of javax.measure.IncommensurableException in project unit-api by unitsofmeasurement.
the class TestUnit method getConverterToAny.
public UnitConverter getConverterToAny(Unit<?> that) throws IncommensurableException, UnconvertibleException {
if (!isCompatible(that))
throw new IncommensurableException(this + " is not compatible with " + that);
// Since both units are
TestUnit thatAbstr = (TestUnit) that;
// compatible they must
// be both test
// units.
Unit thisSystemUnit = this.getSystemUnit();
UnitConverter thisToDimension = this.getSystemConverter();
Unit thatSystemUnit = thatAbstr.getSystemUnit();
UnitConverter thatToDimension = thatAbstr.getSystemConverter();
return thatToDimension.inverse().concatenate(thisToDimension);
}
Aggregations