castFrom<K, V, K2, V2> static method
StreamMap<K2, V2>
castFrom<K, V, K2, V2>(
- Map<
K, V> source, { - OnUpdate<
Map< ? onUpdate,K2, V2> > - OnEvent<
CollectionEvent< ? onEvent,K2, V2> > - OnChange<
CollectionChangeEvent< ? onChange,K2, V2> >
override
Adapts source
to be a StreamMap<K2, V2>
.
Any time the set would produce a key or value that is not a K2
or V2
,
the access will throw.
Any time K2
key or V2
value is attempted added into the adapted map,
the store will throw unless the key is also an instance of K
and
the value is also an instance of V
.
If all accessed entries of source
are have K2
keys and V2
values
and if all entries added to the returned map have K
keys and V
]
values, then the returned map can be used as a Map<K2, V2>
.
Implementation
static StreamMap<K2, V2> castFrom<K, V, K2, V2>(
Map<K, V> source, {
OnUpdate<Map<K2, V2>>? onUpdate,
OnEvent<CollectionEvent<K2, V2>>? onEvent,
OnChange<CollectionChangeEvent<K2, V2>>? onChange,
}) {
return StreamMap<K2, V2>(
value: Map.castFrom(source),
onUpdate: onUpdate,
onEvent: onEvent,
onChange: onChange,
);
}