| OLD | NEW |
| (Empty) |
| 1 // Copyright 2013 Google Inc. All Rights Reserved. | |
| 2 // | |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); | |
| 4 // you may not use this file except in compliance with the License. | |
| 5 // You may obtain a copy of the License at | |
| 6 // | |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 | |
| 8 // | |
| 9 // Unless required by applicable law or agreed to in writing, software | |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, | |
| 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 12 // See the License for the specific language governing permissions and | |
| 13 // limitations under the License. | |
| 14 | |
| 15 part of quiver.collection; | |
| 16 | |
| 17 /** | |
| 18 * An implementation of [Map] that delegates all methods to another [Map]. | |
| 19 * For instance you can create a FruitMap like this : | |
| 20 * | |
| 21 * class FruitMap extends DelegatingMap<String, Fruit> { | |
| 22 * final Map<String, Fruit> _fruits = {}; | |
| 23 * | |
| 24 * Map<String, Fruit> get delegate => _fruits; | |
| 25 * | |
| 26 * // custom methods | |
| 27 * } | |
| 28 */ | |
| 29 abstract class DelegatingMap<K, V> implements Map<K, V> { | |
| 30 Map<K, V> get delegate; | |
| 31 | |
| 32 V operator [](Object key) => delegate[key]; | |
| 33 | |
| 34 void operator []=(K key, V value) { | |
| 35 delegate[key] = value; | |
| 36 } | |
| 37 | |
| 38 void addAll(Map<K, V> other) => delegate.addAll(other); | |
| 39 | |
| 40 void clear() => delegate.clear(); | |
| 41 | |
| 42 bool containsKey(Object key) => delegate.containsKey(key); | |
| 43 | |
| 44 bool containsValue(Object value) => delegate.containsValue(value); | |
| 45 | |
| 46 void forEach(void f(K key, V value)) => delegate.forEach(f); | |
| 47 | |
| 48 bool get isEmpty => delegate.isEmpty; | |
| 49 | |
| 50 bool get isNotEmpty => delegate.isNotEmpty; | |
| 51 | |
| 52 Iterable<K> get keys => delegate.keys; | |
| 53 | |
| 54 int get length => delegate.length; | |
| 55 | |
| 56 V putIfAbsent(K key, V ifAbsent()) => delegate.putIfAbsent(key, ifAbsent); | |
| 57 | |
| 58 V remove(Object key) => delegate.remove(key); | |
| 59 | |
| 60 Iterable<V> get values => delegate.values; | |
| 61 } | |
| OLD | NEW |