getObjectWithType method
Returns an object that references a component registered for type
.
The returned object is always a reference object; it does not contain actual values.
An object is always returned, even if no component named has been registered
for type
. If after APIDocumentContext.finalize is called and no object
has been registered for type
, an error is thrown.
Implementation
T getObjectWithType(Type type) {
final obj = _getInstanceOf()!;
obj.referenceURI =
Uri(path: "/components/$_typeName/aqueduct-typeref:$type");
if (_typeReferenceMap.containsKey(type)) {
obj.referenceURI = _typeReferenceMap[type]!.referenceURI;
} else {
final completer =
_resolutionMap.putIfAbsent(type, () => Completer<T>.sync());
completer.future.then((refObject) {
obj.referenceURI = refObject!.referenceURI;
});
}
return obj;
}