DefaultObjectProvider<T> class
Default implementation of ObjectProvider in Jetleaf.
This class is responsible for retrieving pods (objects) from the PodFactory and exposing them through a consistent provider interface.
It supports both direct retrieval (via get) and streaming (via stream).
Example
final provider = DefaultObjectProvider<MyService>(
'myServicePod',
factory,
[ObjectHolder(MyService())],
);
// Retrieve an object
final holder = await provider.get();
print(holder.object);
// Stream objects
await for (final obj in provider.stream()) {
print('Received: ${obj.object}');
}
This is part of Jetleaf – a framework which developers can use to build web applications.
- Inheritance
-
- Object
- ObjectFactory<
T> - ObjectProvider<
T> - DefaultObjectProvider
- Annotations
-
- @Generic.new(DefaultObjectProvider)
Constructors
-
DefaultObjectProvider(String _podName, PodFactory _factory, List<
ObjectHolder< objects)T> > - Default implementation of ObjectProvider in Jetleaf.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- isEmpty → bool
-
Returns
trueif no objects are available.no setterinherited - isNotEmpty → bool
-
Returns
trueif at least one object is available.no setterinherited -
objects
→ List<
ObjectHolder< T> > -
The list of pre-registered ObjectHolder instances.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
chain<
R> (ObjectFactory< R> nextFactory(T)) → Future<ObjectFactory< R> > -
Creates a new ObjectFactory that uses this factory's output as input to another factory.
inherited
-
copyWith(
{ObjectFactoryFunction< T> ? creator}) → ObjectFactory<T> -
Creates a copy of this ObjectFactory with a new creator function.
inherited
-
createMultiple(
int count) → Future< List< T> > -
Creates multiple instances of type
Tin a single call.inherited -
get(
[List< ArgumentValue> ? args]) → FutureOr<ObjectHolder< T> > -
Retrieves the single object instance or throws if none or more than one found.
override
-
getIfAvailable(
[Supplier< ObjectHolder< ? supplier]) → Future<T> >ObjectHolder< T> ?> -
Retrieves the object if available, or returns
nullif none exist.inherited -
getIfUnique(
[Supplier< ObjectHolder< ? supplier]) → Future<T> >ObjectHolder< T> ?> -
Retrieves the object only if exactly one instance exists, or returns
null.inherited -
ifAvailable(
Consumer< ObjectHolder< consumer) → Future<T> >void> -
Executes
consumerif the object is available.inherited -
ifUnique(
Consumer< ObjectHolder< consumer) → Future<T> >void> -
Executes
consumeronly if exactly one instance is available.inherited -
iterator(
) → Iterator< T> -
Returns an iterator over all available objects.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
stream(
) → GenericStream< ObjectHolder< T> > -
Returns a
GenericStreamof all available objects.override -
toList(
) → List< T> -
Returns a list of all available objects.
inherited
-
toString(
) → String -
Returns a string representation of this ObjectFactory.
inherited
-
withSideEffect(
void sideEffect(T)) → Future< ObjectFactory< T> > -
Creates a new factory that performs a side effect after object creation.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited