References class

The most basic implementation of IReferences to store and locate component references.

See IReferences

Example

class MyController implements IReferenceable {
    IMyPersistence persistence;
    ...
    void setReferences(IReferences references) {
        persistence = references.getOneRequired<IMyPersistence>(
             Descriptor('mygroup', 'persistence', '*', '*', '1.0')
        );
    }
    ...
}

var persistence =  MyMongoDbPersistence();

var controller =  MyController();

var references = References.fromTuples([
     Descriptor('mygroup', 'persistence', 'mongodb', 'default', '1.0'), persistence,
     Descriptor('mygroup', 'controller', 'default', 'default', '1.0'), controller
]);
controller.setReferences(references);
Implemented types

Constructors

References([List? tuples])
Creates a new instance of references and initializes it with references.

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

find<T>(dynamic locator, bool required) List<T>
Gets all component references that match specified locator.
override
getAll() List
Gets all component references registered in this reference map.
override
getAllLocators() List
Gets locators for all registered component references in this reference map.
override
getOneOptional<T>(dynamic locator) → T?
Gets an optional component reference that matches specified locator.
override
getOneRequired<T>(dynamic locator) → T
Gets a required component reference that matches specified locator.
override
getOptional<T>(dynamic locator) List<T>
Gets all component references that match specified locator.
override
getRequired<T>(dynamic locator) List<T>
Gets all component references that match specified locator. At least one component reference must be present. If it doesn't the method throws an error.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
put(dynamic locator, dynamic component) → void
Puts a new reference into this reference map.
override
remove(dynamic locator) → dynamic
Removes a previously added reference that matches specified locator. If many references match the locator, it removes only the first one. When all references shall be removed, use removeAll method instead.
override
removeAll(dynamic locator) List
Removes all component references that match the specified locator.
override
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

fromTuples(List tuples) References
Creates a new References from a list of key-value pairs called tuples.