| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * Wrappers that prevent a List, Set, or Map object from being modified. | 6 * Wrappers that prevent a List, Set, or Map object from being modified. |
| 7 * | 7 * |
| 8 * The [Set] and [Map] wrappers allow reading from the wrapped collection, | 8 * The [Set] and [Map] wrappers allow reading from the wrapped collection, |
| 9 * but prohibit writing. | 9 * but prohibit writing. |
| 10 * | 10 * |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 class NonGrowableListView<E> extends DelegatingList<E> | 29 class NonGrowableListView<E> extends DelegatingList<E> |
| 30 with NonGrowableListMixin<E> { | 30 with NonGrowableListMixin<E> { |
| 31 NonGrowableListView(List<E> listBase) : super(listBase); | 31 NonGrowableListView(List<E> listBase) : super(listBase); |
| 32 } | 32 } |
| 33 | 33 |
| 34 /** | 34 /** |
| 35 * Mixin class that implements a throwing version of all list operations that | 35 * Mixin class that implements a throwing version of all list operations that |
| 36 * change the List's length. | 36 * change the List's length. |
| 37 */ | 37 */ |
| 38 abstract class NonGrowableListMixin<E> implements List<E> { | 38 abstract class NonGrowableListMixin<E> implements List<E> { |
| 39 static void _throw() { | 39 static _throw() { |
| 40 throw new UnsupportedError( | 40 throw new UnsupportedError( |
| 41 "Cannot change the length of a fixed-length list"); | 41 "Cannot change the length of a fixed-length list"); |
| 42 } | 42 } |
| 43 | 43 |
| 44 /** | 44 /** |
| 45 * Throws an [UnsupportedError]; | 45 * Throws an [UnsupportedError]; |
| 46 * operations that change the length of the list are disallowed. | 46 * operations that change the length of the list are disallowed. |
| 47 */ | 47 */ |
| 48 void set length(int newLength) => _throw(); | 48 void set length(int newLength) => _throw(); |
| 49 | 49 |
| 50 /** | 50 /** |
| 51 * Throws an [UnsupportedError]; | 51 * Throws an [UnsupportedError]; |
| 52 * operations that change the length of the list are disallowed. | 52 * operations that change the length of the list are disallowed. |
| 53 */ | 53 */ |
| 54 bool add(E value) { | 54 bool add(E value) => _throw(); |
| 55 _throw(); | |
| 56 } | |
| 57 | 55 |
| 58 /** | 56 /** |
| 59 * Throws an [UnsupportedError]; | 57 * Throws an [UnsupportedError]; |
| 60 * operations that change the length of the list are disallowed. | 58 * operations that change the length of the list are disallowed. |
| 61 */ | 59 */ |
| 62 void addAll(Iterable<E> iterable) => _throw(); | 60 void addAll(Iterable<E> iterable) => _throw(); |
| 63 | 61 |
| 64 /** | 62 /** |
| 65 * Throws an [UnsupportedError]; | 63 * Throws an [UnsupportedError]; |
| 66 * operations that change the length of the list are disallowed. | 64 * operations that change the length of the list are disallowed. |
| 67 */ | 65 */ |
| 68 void insert(int index, E element) => _throw(); | 66 void insert(int index, E element) => _throw(); |
| 69 | 67 |
| 70 /** | 68 /** |
| 71 * Throws an [UnsupportedError]; | 69 * Throws an [UnsupportedError]; |
| 72 * operations that change the length of the list are disallowed. | 70 * operations that change the length of the list are disallowed. |
| 73 */ | 71 */ |
| 74 void insertAll(int index, Iterable<E> iterable) => _throw(); | 72 void insertAll(int index, Iterable<E> iterable) => _throw(); |
| 75 | 73 |
| 76 /** | 74 /** |
| 77 * Throws an [UnsupportedError]; | 75 * Throws an [UnsupportedError]; |
| 78 * operations that change the length of the list are disallowed. | 76 * operations that change the length of the list are disallowed. |
| 79 */ | 77 */ |
| 80 bool remove(Object value) { _throw(); } | 78 bool remove(Object value) => _throw(); |
| 81 | 79 |
| 82 /** | 80 /** |
| 83 * Throws an [UnsupportedError]; | 81 * Throws an [UnsupportedError]; |
| 84 * operations that change the length of the list are disallowed. | 82 * operations that change the length of the list are disallowed. |
| 85 */ | 83 */ |
| 86 E removeAt(int index) { _throw(); } | 84 E removeAt(int index) => _throw(); |
| 87 | 85 |
| 88 /** | 86 /** |
| 89 * Throws an [UnsupportedError]; | 87 * Throws an [UnsupportedError]; |
| 90 * operations that change the length of the list are disallowed. | 88 * operations that change the length of the list are disallowed. |
| 91 */ | 89 */ |
| 92 E removeLast() { _throw(); } | 90 E removeLast() => _throw(); |
| 93 | 91 |
| 94 /** | 92 /** |
| 95 * Throws an [UnsupportedError]; | 93 * Throws an [UnsupportedError]; |
| 96 * operations that change the length of the list are disallowed. | 94 * operations that change the length of the list are disallowed. |
| 97 */ | 95 */ |
| 98 void removeWhere(bool test(E element)) => _throw(); | 96 void removeWhere(bool test(E element)) => _throw(); |
| 99 | 97 |
| 100 /** | 98 /** |
| 101 * Throws an [UnsupportedError]; | 99 * Throws an [UnsupportedError]; |
| 102 * operations that change the length of the list are disallowed. | 100 * operations that change the length of the list are disallowed. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 class UnmodifiableSetView<E> extends DelegatingSet<E> | 132 class UnmodifiableSetView<E> extends DelegatingSet<E> |
| 135 with UnmodifiableSetMixin<E> { | 133 with UnmodifiableSetMixin<E> { |
| 136 UnmodifiableSetView(Set<E> setBase) : super(setBase); | 134 UnmodifiableSetView(Set<E> setBase) : super(setBase); |
| 137 } | 135 } |
| 138 | 136 |
| 139 /** | 137 /** |
| 140 * Mixin class that implements a throwing version of all set operations that | 138 * Mixin class that implements a throwing version of all set operations that |
| 141 * change the Set. | 139 * change the Set. |
| 142 */ | 140 */ |
| 143 abstract class UnmodifiableSetMixin<E> implements Set<E> { | 141 abstract class UnmodifiableSetMixin<E> implements Set<E> { |
| 144 void _throw() { | 142 _throw() { |
| 145 throw new UnsupportedError("Cannot modify an unmodifiable Set"); | 143 throw new UnsupportedError("Cannot modify an unmodifiable Set"); |
| 146 } | 144 } |
| 147 | 145 |
| 148 /** | 146 /** |
| 149 * Throws an [UnsupportedError]; | 147 * Throws an [UnsupportedError]; |
| 150 * operations that change the set are disallowed. | 148 * operations that change the set are disallowed. |
| 151 */ | 149 */ |
| 152 bool add(E value) { | 150 bool add(E value) => _throw(); |
| 153 _throw(); | |
| 154 } | |
| 155 | 151 |
| 156 /** | 152 /** |
| 157 * Throws an [UnsupportedError]; | 153 * Throws an [UnsupportedError]; |
| 158 * operations that change the set are disallowed. | 154 * operations that change the set are disallowed. |
| 159 */ | 155 */ |
| 160 void addAll(Iterable<E> elements) => _throw(); | 156 void addAll(Iterable<E> elements) => _throw(); |
| 161 | 157 |
| 162 /** | 158 /** |
| 163 * Throws an [UnsupportedError]; | 159 * Throws an [UnsupportedError]; |
| 164 * operations that change the set are disallowed. | 160 * operations that change the set are disallowed. |
| 165 */ | 161 */ |
| 166 bool remove(Object value) { _throw(); } | 162 bool remove(Object value) => _throw(); |
| 167 | 163 |
| 168 /** | 164 /** |
| 169 * Throws an [UnsupportedError]; | 165 * Throws an [UnsupportedError]; |
| 170 * operations that change the set are disallowed. | 166 * operations that change the set are disallowed. |
| 171 */ | 167 */ |
| 172 void removeAll(Iterable elements) => _throw(); | 168 void removeAll(Iterable elements) => _throw(); |
| 173 | 169 |
| 174 /** | 170 /** |
| 175 * Throws an [UnsupportedError]; | 171 * Throws an [UnsupportedError]; |
| 176 * operations that change the set are disallowed. | 172 * operations that change the set are disallowed. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 class UnmodifiableMapView<K, V> extends DelegatingMap<K, V> | 204 class UnmodifiableMapView<K, V> extends DelegatingMap<K, V> |
| 209 with UnmodifiableMapMixin<K, V> { | 205 with UnmodifiableMapMixin<K, V> { |
| 210 UnmodifiableMapView(Map<K, V> baseMap) : super(baseMap); | 206 UnmodifiableMapView(Map<K, V> baseMap) : super(baseMap); |
| 211 } | 207 } |
| 212 | 208 |
| 213 /** | 209 /** |
| 214 * Mixin class that implements a throwing version of all map operations that | 210 * Mixin class that implements a throwing version of all map operations that |
| 215 * change the Map. | 211 * change the Map. |
| 216 */ | 212 */ |
| 217 abstract class UnmodifiableMapMixin<K, V> implements Map<K, V> { | 213 abstract class UnmodifiableMapMixin<K, V> implements Map<K, V> { |
| 218 static void _throw() { | 214 static _throw() { |
| 219 throw new UnsupportedError("Cannot modify an unmodifiable Map"); | 215 throw new UnsupportedError("Cannot modify an unmodifiable Map"); |
| 220 } | 216 } |
| 221 | 217 |
| 222 /** | 218 /** |
| 223 * Throws an [UnsupportedError]; | 219 * Throws an [UnsupportedError]; |
| 224 * operations that change the map are disallowed. | 220 * operations that change the map are disallowed. |
| 225 */ | 221 */ |
| 226 void operator []=(K key, V value) => _throw(); | 222 void operator []=(K key, V value) => _throw(); |
| 227 | 223 |
| 228 /** | 224 /** |
| 229 * Throws an [UnsupportedError]; | 225 * Throws an [UnsupportedError]; |
| 230 * operations that change the map are disallowed. | 226 * operations that change the map are disallowed. |
| 231 */ | 227 */ |
| 232 V putIfAbsent(K key, V ifAbsent()) { _throw(); } | 228 V putIfAbsent(K key, V ifAbsent()) => _throw(); |
| 233 | 229 |
| 234 /** | 230 /** |
| 235 * Throws an [UnsupportedError]; | 231 * Throws an [UnsupportedError]; |
| 236 * operations that change the map are disallowed. | 232 * operations that change the map are disallowed. |
| 237 */ | 233 */ |
| 238 void addAll(Map<K, V> other) => _throw(); | 234 void addAll(Map<K, V> other) => _throw(); |
| 239 | 235 |
| 240 /** | 236 /** |
| 241 * Throws an [UnsupportedError]; | 237 * Throws an [UnsupportedError]; |
| 242 * operations that change the map are disallowed. | 238 * operations that change the map are disallowed. |
| 243 */ | 239 */ |
| 244 V remove(K key) { _throw(); } | 240 V remove(K key) => _throw(); |
| 245 | 241 |
| 246 /** | 242 /** |
| 247 * Throws an [UnsupportedError]; | 243 * Throws an [UnsupportedError]; |
| 248 * operations that change the map are disallowed. | 244 * operations that change the map are disallowed. |
| 249 */ | 245 */ |
| 250 void clear() => _throw(); | 246 void clear() => _throw(); |
| 251 } | 247 } |
| OLD | NEW |