create<T extends Object?> method
T?
create<T extends Object?>(
- InstanceBuilder<
T> builder, { - String? id,
- Object? ref,
- InstanceManageMode mode = InstanceManageMode.builder,
Registers, creates and/or gets the instance of T
with an id
optional.
Use mode
parameter for defining how to manage the instance.
Under the following conditions:
- if not found and hasn't registered it, registers, creates and returns it.
- if not found and has registered it, creates and returns it.
- if found it, returns it.
- else return
null
.
Implementation
T? create<T extends Object?>(
InstanceBuilder<T> builder, {
String? id,
Object? ref,
InstanceManageMode mode = InstanceManageMode.builder,
}) {
register<T>(builder, id: id, mode: mode);
return _getOrCreateIfNotExtist<T>(id, ref)?.instance;
}