@@ -134,19 +134,9 @@ public static ImmutableMapValue emptyMap() {
134134 }
135135
136136
137- public static class MapEntry {
138- public final Value key ;
139- public final Value value ;
140-
141- public MapEntry (Value key , Value value ) {
142- this .key = key ;
143- this .value = value ;
144- }
145- }
146-
147- public static MapValue newMap (MapEntry ... pairs ) {
137+ public static MapValue newMap (Map .Entry <? extends Value , ? extends Value >... pairs ) {
148138 MapBuilder b = new MapBuilder ();
149- for (MapEntry p : pairs ) {
139+ for (Map . Entry <? extends Value , ? extends Value > p : pairs ) {
150140 b .put (p );
151141 }
152142 return b .build ();
@@ -157,26 +147,38 @@ public static MapBuilder newMapBuilder() {
157147 return new MapBuilder ();
158148 }
159149
160- public static MapEntry newMapEntry (Value key , Value value ) {
161- return new MapEntry (key , value );
150+ public static Map . Entry < Value , Value > newMapEntry (Value key , Value value ) {
151+ return new AbstractMap . SimpleEntry < Value , Value > (key , value );
162152
163153 }
164154
165155 public static class MapBuilder {
166- private Map <Value , Value > map = new HashMap <Value , Value >();
156+ private final Map <Value , Value > map = new HashMap <Value , Value >();
167157 public MapBuilder () {}
168158
169159 public MapValue build () {
170160 return newMap (map );
171161 }
172162
173- public void put (MapEntry pair ) {
174- put (pair .key , pair .value );
163+ public void put (Map . Entry <? extends Value , ? extends Value > pair ) {
164+ put (pair .getKey () , pair .getValue () );
175165 }
176166
177167 public void put (Value key , Value value ) {
178168 map .put (key , value );
179169 }
170+
171+ public void putAll (Iterable <? extends Map .Entry <? extends Value ,? extends Value >> entries ){
172+ for (Map .Entry <? extends Value , ? extends Value > entry : entries ) {
173+ put (entry .getKey (), entry .getValue ());
174+ }
175+ }
176+
177+ public void putAll (Map <? extends Value , ? extends Value > map ) {
178+ for (Map .Entry <? extends Value , ? extends Value > entry : map .entrySet ()) {
179+ put (entry );
180+ }
181+ }
180182 }
181183
182184 public static ImmutableExtensionValue newExtension (byte type , byte [] data ) {
0 commit comments