Mapper
- class automapper.mapper.Mapper
Class that maps objects from one class to another based on the type hints
- Returns:
_type_: _description_
- add_custom_mapping(source_class: Type, source_field: str, target_field: str)
Add a custom mapping between a source field and a target field
- Args:
source_class (Type): source class source_field (str): name of the source field target_field (str): name of the target field
- get_source_fields(source: TSource) Dict[str, Type] | None
Get the fields of the source object and map them to their types
- Args:
source (TSource): source object
- Returns:
Dict[str, Type]: a dictionary with the fields and their types
- map(source: TSource, target_class: Type[TMapTarget]) TMapTarget
Recursive function that maps the source object to the target class
- Args:
source (TSource): source object target_class (Type[TMapTarget]): type of the target object
- Returns:
TMapTarget: _description_
- map_dict(source_dict: Dict, target_inner_type: Type) Dict | None
Map a dictionary of objects to another dictionary of objects
- Args:
source_dict (Dict): _description_ target_inner_type (Type): _description_
- Returns:
Dict | None: _description_
- map_enum(source_value: Enum, target_field_type)
Map an Enum value to another Enum of the target field type
- Args:
source_value (_type_): _description_ target_field_type (_type_): _description_
- Returns:
_type_: _description_
- map_list(source_list: List, target_inner_type: Type) List | None
Map a list of objects to another list of objects
- Args:
source_list (List): _description_ target_inner_type (Type): _description_
- Returns:
List | None: _description_