preprocessSetDiff<T> function
Implementation
SetDiffs<T>? preprocessSetDiff<T>(SetDiffArguments<T> args) {
final oldIsEmpty = args.original.isEmpty;
final newIsEmpty = args.replacement.isEmpty;
if (oldIsEmpty && newIsEmpty) {
return SetDiffs<T>.empty(args);
}
if (oldIsEmpty) {
final replacement = args.replacement.toSet();
return SetDiffs.ofOperations(
[SetDiff.add(args, replacement)], replacement, args);
}
if (newIsEmpty) {
final replacement = args.original.toSet();
return SetDiffs.ofOperations(
[SetDiff.remove(args, replacement)], replacement, args);
}
return null;
}