convertPairedInstances method

  1. @override
Object? convertPairedInstances(
  1. InstanceManager manager,
  2. Object? object
)
override

Converts PairedInstances to objects stored in manager.

Conversions:

  • PairedInstances are converted to the object instance they're paired to.
  • Lists are converted to List<Object?> and this method is applied to each value within the list.
  • Maps are converted to Map<Object?, Object?> and this method is applied to each key and each value.

Implementation

@override
Object? convertPairedInstances(InstanceManager manager, Object? object) {
  if (object is PairedInstance) {
    return manager.getInstance(object.instanceId);
  } else if (object is List) {
    return object
        .map<Object?>((_) => convertPairedInstances(manager, _))
        .toList();
  } else if (object is Map) {
    return Map<Object?, Object?>.fromIterables(
      object.keys.map<Object?>((_) => convertPairedInstances(manager, _)),
      object.values.map<Object?>((_) => convertPairedInstances(manager, _)),
    );
  }

  return object;
}