compareTo method

  1. @override
int compareTo(
  1. dynamic entity
)
override

Compares two entities based on codes, ids or attributes. If the result is less than 0 then the first entity is less than the second, if it is equal to 0 they are equal and if the result is greater than 0 then the first is greater than the second.

Implementation

@override
int compareTo(entity) {
  if (code?.isNotEmpty ?? false) {
    return _code!.compareTo(entity.code!);
  } else if (entity.id != null && id != null) {
    return id!.compareTo(entity.id);
  } else if (concept.attributes.isNotEmpty) {
    return compareAttributes(entity);
  } else {
    String msg = '${_concept!.code!} concept does not have attributes.';
    throw IdException(msg);
  }
}