operator < method

bool operator <(
  1. Object other
)

Implementation

bool operator <(Object other) {
  if (other is UcumDecimal) {
    return value.comparesTo(other) < 0;
  } else if (other is ValidatedQuantity) {
    final UcumDecimal compareValue =
        UcumService().convert(other.value, other.unit, unit);
    return value.comparesTo(compareValue) < 0;
  } else if (other is num || other is BigInt) {
    return value.comparesTo(UcumDecimal.fromString(other.toString())) < 0;
  } else if (other is String) {
    final ValidatedQuantity newQuantity = ValidatedQuantity.fromString(other);
    if (newQuantity.isValid()) {
      return value.comparesTo(newQuantity.value) < 0;
    } else {
      throw UcumException('> could not be performed on $this and $other '
          '(reason: it is not an accepted type)');
    }
  } else {
    throw UcumException('> could not be performed on $this and $other '
        '(reason: it is not an accepted type)');
  }
}