transform method

Unit transform(
  1. UnitConverter operation
)

Returns the unit derived from this unit using the specified converter.

Implementation

Unit transform(UnitConverter operation) {
  if (this is TransformedUnit) {
    TransformedUnit tf = this as TransformedUnit;
    var parent = tf.parentUnit;
    var toParent = tf.toParentUnit.concatenate(operation);
    if (toParent == UnitConverter.identity) return parent;
    return TransformedUnit(parent, toParent);
  }
  if (operation == UnitConverter.identity) return this;
  return TransformedUnit(this, operation);
}