whenCompared method
Compares two objects using order metadata.
This method provides the actual comparison logic, handling both the standard comparison and the source provider-based comparison when configured.
Parameters:
o1
: The first object to compare, may be nullo2
: The second object to compare, may be null
Returns:
-1
ifo1
should come beforeo2
1
ifo2
should come beforeo1
0
if order is equal or both objects are null
Null Handling:
- Null objects are treated as having the lowest possible precedence
- A non-null object always comes before a null object
- Two null objects are considered equal
Implementation
int whenCompared(Object? o1, Object? o2) {
if (_comparator != null && o1 != null && o2 != null) {
return _comparator!.compare(o1, o2);
}
return doCompare(o1, o2);
}