- @override
Converts a value to a more complex value from a primitive value according to this instance's definition.
This method takes a non-Dart representation of a value (e.g. an HTTP body or database query) and turns it into a Dart representation . How this value is computed depends on this instance's definition.
Source
@override dynamic convertFromPrimitiveValue(dynamic value) { if (value == null) { return null; } if (relationshipType == ManagedRelationshipType.belongsTo || relationshipType == ManagedRelationshipType.hasOne) { if (value is! Map<String, dynamic>) { throw new QueryException(QueryExceptionEvent.requestFailure, message: "Expecting a Map for ${MirrorSystem.getName(destinationEntity.instanceType.simpleName)} in the '$name' field, got '$value' instead."); } ManagedObject instance = destinationEntity.instanceType .newInstance(new Symbol(""), []).reflectee; instance.readFromMap(value as Map<String, dynamic>); return instance; } /* else if (relationshipType == ManagedRelationshipType.hasMany) { */ if (value is! List<Map<String, dynamic>>) { throw new QueryException(QueryExceptionEvent.requestFailure, message: "Expecting a List for ${MirrorSystem.getName(destinationEntity.instanceType.simpleName)} in the '$name' field, got '$value' instead."); } if (value.length > 0 && value.first is! Map) { throw new QueryException(QueryExceptionEvent.requestFailure, message: "Expecting a List<Map> for ${MirrorSystem.getName(destinationEntity.instanceType.simpleName)} in the '$name' field, got '$value' instead."); } return new ManagedSet.from( (value as List<Map<String, dynamic>>).map((v) { ManagedObject instance = destinationEntity.instanceType .newInstance(new Symbol(""), []).reflectee; instance.readFromMap(v); return instance; })); }