MapObject constructor
MapObject({
- required Type type,
- required MapFunction function,
- MapObject? parent,
A configurable value transformer that applies type-specific mapping rules to objects.
This implements a chainable transformation pipeline that:
- Processes values through parent mappings first (if any)
- Applies type-specific transformations
- Preserves unmapped types unchanged
Core Features:
- Type-Specific Handling: Different transformations per type
- Chained Execution: Parent-child mapping composition
- Null Safety: Handles null inputs gracefully
- Immutability: All mappings are final after creation
Example Usage:
// Create mapper for specific types
final mapper = MapObject(
type: String,
function: (s) => s.toUpperCase(),
parent: anotherMapper
);
// Apply transformations
mapper(123); // Returns 123 (unchanged)
mapper('text'); // Returns 'TEXT'
Implementation
MapObject({required Type type, required MapFunction function, MapObject? parent})
: map = Map.unmodifiable(<Type,MapFunction>{type: function}), parent = parent is MapObject ? parent : null;