constructors method

  1. @override
Map<String, Map<String, TypeInfo>>? constructors([
  1. O? o
])
override

The constructors of the Entity. If not implemented returns null.

Implementation

@override
Map<String, Map<String, TypeInfo>>? constructors([O? o]) {
  if (_constructors == null) {
    var reflection = reflectionWithObject(o);

    var map = reflection.allConstructors().map((c) {
      var name = c.name;
      var args = c.allParameters
          .map((p) => MapEntry(p.jsonName, p.type.typeInfo))
          .toMapFromEntries();
      return MapEntry(name, UnmodifiableMapView(args));
    }).toMapFromEntries();

    _constructors = UnmodifiableMapView(map);
  }

  return _constructors!;
}