operator % method
Implementation
ValidatedQuantity operator %(Object other) {
if (other is UcumDecimal) {
return copyWith(value: value.modulo(other));
} else if (other is ValidatedQuantity) {
return copyWith(value: value.modulo(other.value));
} else if (other is num || other is BigInt) {
return copyWith(
value: value.modulo(UcumDecimal.fromString(other.toString())));
} else if (other is String) {
final ValidatedQuantity newQuantity = ValidatedQuantity.fromString(other);
if (newQuantity.isValid()) {
return copyWith(value: value.modulo(newQuantity.value));
} else {
throw UcumException('$this could not be moduloed with $other '
'(reason: it is not an accepted type)');
}
} else {
throw UcumException('$this could not be moduloed with $other '
'(reason: it is not an accepted type)');
}
}