haive.core.utils.getter_mixin¶
Collection utilities for Haive Core - GetterMixin.
This module includes powerful retrieval and filtering utilities for collection classes.
Classes¶
A mixin providing rich lookup and filtering capabilities for collections. |
Module Contents¶
- class haive.core.utils.getter_mixin.GetterMixin[source]¶
Bases:
Generic
[T
]A mixin providing rich lookup and filtering capabilities for collections.
This mixin can be added to any collection class that implements _get_items() to provide powerful querying capabilities.
- filter(**kwargs)[source]¶
Filter items by multiple attribute criteria.
- Parameters:
**kwargs – Field name and value pairs to match
- Returns:
List of matching items
- Return type:
list[T]
- find(predicate)[source]¶
Find first item matching a custom predicate function.
- Parameters:
predicate (collections.abc.Callable[[T], bool]) – Function that takes item and returns boolean
- Returns:
First matching item or None
- Return type:
T | None
- find_all(predicate)[source]¶
Find all items matching a custom predicate function.
- Parameters:
predicate (collections.abc.Callable[[T], bool]) – Function that takes item and returns boolean
- Returns:
List of matching items
- Return type:
list[T]
- first(**kwargs)[source]¶
Get first item matching criteria.
- Parameters:
**kwargs – Field name and value pairs to match
- Returns:
First matching item or None
- Return type:
T | None