MapperContainer class abstract Generics Mapper Container

The mapper container manages a set of mappers and is the main interface for accessing mapping functionalities.

MapperContainers are the backbone of dart_mappable. A MapperContainers job is to lookup the correct mapper for a given type or value and call its respective method. To find the mapper for a given type, the container first looks at its own set of mappers and when there is no match it refers to its linked containers.

Annotations
  • @sealed

Constructors

MapperContainer({Set<MapperBase<Object>>? mappers, Set<MapperContainer>? linked, Map<String, Function>? types})
factory

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

asString(dynamic value) String
Returns the string representation of a value.
fromIterable<T>(Iterable iterable) → T
Decodes an iterable to a given type T.
fromJson<T>(String json) → T
Decodes a json string to a given type T.
fromMap<T>(Map<String, dynamic> map) → T
Decodes a map to a given type T.
fromValue<T>(Object? value, [DecodingOptions? options]) → T
The core method to decode any value to a given type T.
get<T extends Object>([Type? type]) MapperBase<T>?
Returns the current mapper for type T of this container.
getAll() List<MapperBase<Object>>
Returns all mapper this container currently holds.
hash(dynamic value) int
Calculates the hash of a value.
override
isEqual(dynamic value, Object? other) bool
Checks whether two values are deeply equal.
Links another container to this container.
linkAll(Iterable<MapperContainer> containers) → void
Links a list of containers to this container.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toIterable<T>(T object) Iterable
Encodes a value to an iterable.
toJson<T>(T object) String
Encodes a value to a json string.
toMap<T>(T object) Map<String, dynamic>
Encodes a value to a map.
toString() String
A string representation of this object.
inherited
toValue<T>(T? value, [EncodingOptions? options]) → dynamic
The core method to encode any value.
unuse<T extends Object>() MapperBase<T>?
Removes the mapper for type T this container currently holds.
use<T extends Object>(MapperBase<T> mapper) → void
Adds a new mapper to the set of mappers this container holds.
useAll(Iterable<MapperBase<Object>> mappers) → void
Adds a list of mappers to the set of mappers this container holds.

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Properties

defaults MapperContainer
A container that holds the standard set of mappers for all core types, including all primitives, List, Set, Map and DateTime.
final
globals MapperContainer
A container that holds all globally registered mappers.
final