| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 library protobuf.mixins.map; | 5 library protobuf.mixins.map; |
| 6 | 6 |
| 7 import "package:protobuf/protobuf.dart" show BuilderInfo; | 7 import "package:protobuf/protobuf.dart" show BuilderInfo; |
| 8 | 8 |
| 9 /// A PbMapMixin provides an experimental implementation of the | 9 /// A PbMapMixin provides an experimental implementation of the |
| 10 /// Map interface for a GeneratedMessage. | 10 /// Map interface for a GeneratedMessage. |
| 11 /// | 11 /// |
| 12 /// This mixin is enabled via an option in | 12 /// This mixin is enabled via an option in |
| 13 /// dart_options.proto in dart-protoc-plugin. | 13 /// dart_options.proto in dart-protoc-plugin. |
| 14 abstract class PbMapMixin implements Map { | 14 abstract class PbMapMixin implements Map { |
| 15 | 15 |
| 16 // GeneratedMessage properties and methods used by this mixin. | 16 // GeneratedMessage properties and methods used by this mixin. |
| 17 | 17 |
| 18 BuilderInfo get info_; | 18 BuilderInfo get info_; |
| 19 void clear(); | 19 void clear(); |
| 20 int getTagNumber(String fieldName); | 20 int getTagNumber(String fieldName); |
| 21 getField(int tagNumber); | 21 getField(int tagNumber); |
| 22 void setField(int tagNumber, var value, [int fieldType = null]); | 22 void setField(int tagNumber, var value); |
| 23 | 23 |
| 24 @override | 24 @override |
| 25 operator [](key) { | 25 operator [](key) { |
| 26 if (key is! String) return null; | 26 if (key is! String) return null; |
| 27 var tag = getTagNumber(key); | 27 var tag = getTagNumber(key); |
| 28 if (tag == null) return null; | 28 if (tag == null) return null; |
| 29 return getField(tag); | 29 return getField(tag); |
| 30 } | 30 } |
| 31 | 31 |
| 32 @override | 32 @override |
| (...skipping 14 matching lines...) Expand all Loading... |
| 47 | 47 |
| 48 @override | 48 @override |
| 49 get length => info_.byName.length; | 49 get length => info_.byName.length; |
| 50 | 50 |
| 51 @override | 51 @override |
| 52 remove(key) { | 52 remove(key) { |
| 53 throw new UnsupportedError( | 53 throw new UnsupportedError( |
| 54 "remove() not supported by ${info_.messageName}"); | 54 "remove() not supported by ${info_.messageName}"); |
| 55 } | 55 } |
| 56 } | 56 } |
| OLD | NEW |