pip_services3_container.refer.ReferencesDecorator module¶
pip_services3_container.refer.ReferencesDecorator¶
References decorator implementation.
- copyright
Conceptual Vision Consulting LLC 2018-2019, see AUTHORS for more details.
- license
MIT, see LICENSE for more details.
-
class
pip_services3_container.refer.ReferencesDecorator.
ReferencesDecorator
(next_references: Optional[pip_services3_commons.refer.IReferences.IReferences], top_references: Optional[pip_services3_commons.refer.IReferences.IReferences])¶ Bases:
pip_services3_commons.refer.IReferences.IReferences
Chainable decorator for
IReferences
that allows to inject additional capabilities such as automatic component creation, automatic registration and opening.-
find
(locator: Any, required: bool) → List[Any]¶ Gets all component references that match specified locator.
- Parameters
locator – the locator to find a component by.
required – forces to raise an exception if no component is found.
- Returns
a list with matching component references.
- Raises
a
ReferenceException
when required is set to true but no references found.
-
get_all
() → List[Any]¶ Gets all component references registered in this component map.
- Returns
a list with component references.
-
get_all_locators
() → List[Any]¶ Gets locators for all registered component references in this component map.
- Returns
a list with component locators.
-
get_one_before
(reference, locator)¶
-
get_one_optional
(locator: Any) → Any¶ Gets an optional component component that matches specified locator.
- Parameters
locator – the locator to find references by.
- Returns
a matching component component or null if nothing was found.
-
get_one_required
(locator: Any) → Any¶ Gets a required component component that matches specified locator.
- Parameters
locator – the locator to find a component by.
- Returns
a matching component component.
- Raises
a
ReferenceException
when no references found.
-
get_optional
(locator: Any) → List[Any]¶ Gets all component references that match specified locator.
- Parameters
locator – the locator to find references by.
- Returns
a list with matching component references or empty list if nothing was found.
-
get_required
(locator: Any) → List[Any]¶ Gets all component references that match specified locator. At least one component component must be present. If it doesn’t the method throws an error.
- Parameters
locator – the locator to find references by.
- Returns
a list with matching component references.
- Raises
a
ReferenceException
when no references found.
-
put
(locator: Any = None, component: Any = None)¶ Puts a new reference into this reference map.
- Parameters
locator – a locator to find the reference by.
component – a component reference to be added.
-
remove
(locator: Any) → Any¶ Removes a previously added component that matches specified locator. If many references match the locator, it removes only the first one. When all references shall be removed, use
remove_all()
method instead.- Parameters
locator – a locator to remove component
- Returns
the removed component component.
-
remove_all
(locator: Any) → List[Any]¶ Removes all component references that match the specified locator.
- Parameters
locator – the locator to remove references by.
- Returns
a list, containing all removed references.
-