deepReplaceValues<T> function

Object? deepReplaceValues<T>(
  1. Object? o,
  2. ValueFilter filter,
  3. ValueReplacer replacer
)

Replaces values applying replacer to values that matches filter.

Implementation

Object? deepReplaceValues<T>(
    Object? o, ValueFilter filter, ValueReplacer replacer) {
  if (o == null) return null;

  if (filter(null, null, o)) {
    return replacer(null, null, o);
  } else if (o is List) {
    deepReplaceListValues(o, filter, replacer);
    return o;
  } else if (o is Map) {
    deepReplaceMapValues(o, filter, replacer);
    return o;
  } else if (o is Set) {
    deepReplaceSetValues(o, filter, replacer);
    return o;
  } else {
    return o;
  }
}