expandDefinedUnit method
Implementation
Canonical expandDefinedUnit(String indent, DefinedUnit unit) {
String? u = unit.value.unit;
UcumDecimal? v = unit.value.value;
if (unit.isSpecial ?? false) {
if (!handlers.exists(unit.code)) {
throw UcumException('Not handled yet (special unit)');
} else {
u = handlers.get(unit.code)?.getUnits();
v = handlers.get(unit.code)?.getValue();
if (handlers.get(unit.code)?.hasOffset() ?? false) {
v = v?.add(handlers.get(unit.code)!.getOffset());
// Handling for special case with offset
// throw UcumException(
// "Not handled yet (special unit with offset from 0 at intersect)");
}
}
}
final Term t = u == null ? Term() : ExpressionParser(model).parse(u);
debugTerm(indent, 'now handle', t);
final Canonical result = normaliseTerm('$indent ', t);
if (v != null) {
result.value = result.value.multiply(v);
}
return result;
}