MapObject class
A configurable mapping system that can transform objects based on their type. Supports chaining through parent mappings and type-specific transformations.
This class is designed to be immutable, meaning once created, the mapping rules cannot be changed. It allows for a flexible and extensible way to handle different types of objects in a consistent manner.
Key Features:
- Type-Specific Mapping: Define how different types should be transformed.
- Parent Mapping: Chain mappings together for more complex transformations.
- Immutability: Once created, the mapping rules cannot be modified.
- Null Safety: Handles null inputs gracefully.
- Type Preservation: Input and output types are preserved.
Constructors
- MapObject.new({required Type type, required MapFunction function, MapObject? parent})
- A configurable value transformer that applies type-specific mapping rules to objects.
- MapObject.from(MapObject map, {MapObject? parent})
- Creates a MapObject from a map, preserving parent chain if provided
-
MapObject.fromEntries(Iterable<
MapEntry< entries, {MapObject? parent})Type, MapFunction> > - Creates a MapObject from multiple mapping entries
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
-
map
→ Map<
Type, MapFunction> -
Immutable mapping rules by type
final
- parent → MapObject?
-
Optional parent mapper for chaining
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
call<
T> (T object, {Cell? cell, dynamic user}) → T - Applies the mapping to an object, walking up the parent chain if needed
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
-
operator [](
Type type) → MapFunction? - Gets the mapping function for a specific type