10 |
|
|
11 |
|
/** |
12 |
|
* This class provides a skeletal implementation of the <tt>Map</tt> |
13 |
< |
* interface, to minimize the effort required to implement this interface. <p> |
13 |
> |
* interface, to minimize the effort required to implement this interface. |
14 |
|
* |
15 |
< |
* To implement an unmodifiable map, the programmer needs only to extend this |
15 |
> |
* <p>To implement an unmodifiable map, the programmer needs only to extend this |
16 |
|
* class and provide an implementation for the <tt>entrySet</tt> method, which |
17 |
|
* returns a set-view of the map's mappings. Typically, the returned set |
18 |
|
* will, in turn, be implemented atop <tt>AbstractSet</tt>. This set should |
19 |
|
* not support the <tt>add</tt> or <tt>remove</tt> methods, and its iterator |
20 |
< |
* should not support the <tt>remove</tt> method.<p> |
20 |
> |
* should not support the <tt>remove</tt> method. |
21 |
|
* |
22 |
< |
* To implement a modifiable map, the programmer must additionally override |
22 |
> |
* <p>To implement a modifiable map, the programmer must additionally override |
23 |
|
* this class's <tt>put</tt> method (which otherwise throws an |
24 |
|
* <tt>UnsupportedOperationException</tt>), and the iterator returned by |
25 |
|
* <tt>entrySet().iterator()</tt> must additionally implement its |
26 |
< |
* <tt>remove</tt> method.<p> |
26 |
> |
* <tt>remove</tt> method. |
27 |
|
* |
28 |
< |
* The programmer should generally provide a void (no argument) and map |
28 |
> |
* <p>The programmer should generally provide a void (no argument) and map |
29 |
|
* constructor, as per the recommendation in the <tt>Map</tt> interface |
30 |
< |
* specification.<p> |
30 |
> |
* specification. |
31 |
|
* |
32 |
< |
* The documentation for each non-abstract methods in this class describes its |
32 |
> |
* <p>The documentation for each non-abstract methods in this class describes its |
33 |
|
* implementation in detail. Each of these methods may be overridden if the |
34 |
< |
* map being implemented admits a more efficient implementation.<p> |
34 |
> |
* map being implemented admits a more efficient implementation. |
35 |
|
* |
36 |
< |
* This class is a member of the |
36 |
> |
* <p>This class is a member of the |
37 |
|
* <a href="{@docRoot}/../guide/collections/index.html"> |
38 |
|
* Java Collections Framework</a>. |
39 |
|
* |
59 |
|
// Query Operations |
60 |
|
|
61 |
|
/** |
62 |
< |
* Returns the number of key-value mappings in this map. If the map |
63 |
< |
* contains more than <tt>Integer.MAX_VALUE</tt> elements, returns |
64 |
< |
* <tt>Integer.MAX_VALUE</tt>.<p> |
62 |
> |
* {@inheritDoc} |
63 |
|
* |
64 |
< |
* This implementation returns <tt>entrySet().size()</tt>. |
67 |
< |
* |
68 |
< |
* @return the number of key-value mappings in this map. |
64 |
> |
* <p>This implementation returns <tt>entrySet().size()</tt>. |
65 |
|
*/ |
66 |
|
public int size() { |
67 |
|
return entrySet().size(); |
68 |
|
} |
69 |
|
|
70 |
|
/** |
71 |
< |
* Returns <tt>true</tt> if this map contains no key-value mappings. <p> |
76 |
< |
* |
77 |
< |
* This implementation returns <tt>size() == 0</tt>. |
71 |
> |
* {@inheritDoc} |
72 |
|
* |
73 |
< |
* @return <tt>true</tt> if this map contains no key-value mappings. |
73 |
> |
* <p>This implementation returns <tt>size() == 0</tt>. |
74 |
|
*/ |
75 |
|
public boolean isEmpty() { |
76 |
|
return size() == 0; |
77 |
|
} |
78 |
|
|
79 |
|
/** |
80 |
< |
* Returns <tt>true</tt> if this map maps one or more keys to this value. |
87 |
< |
* More formally, returns <tt>true</tt> if and only if this map contains |
88 |
< |
* at least one mapping to a value <tt>v</tt> such that <tt>(value==null ? |
89 |
< |
* v==null : value.equals(v))</tt>. This operation will probably require |
90 |
< |
* time linear in the map size for most implementations of <tt>Map</tt>.<p> |
91 |
< |
* |
92 |
< |
* This implementation iterates over <tt>entrySet()</tt> searching for an entry |
93 |
< |
* with the specified value. If such an entry is found, <tt>true</tt> is |
94 |
< |
* returned. If the iteration terminates without finding such an entry, |
95 |
< |
* <tt>false</tt> is returned. Note that this implementation requires |
96 |
< |
* linear time in the size of the map. |
80 |
> |
* {@inheritDoc} |
81 |
|
* |
82 |
< |
* @param value value whose presence in this map is to be tested. |
82 |
> |
* <p>This implementation iterates over <tt>entrySet()</tt> searching |
83 |
> |
* for an entry with the specified value. If such an entry is found, |
84 |
> |
* <tt>true</tt> is returned. If the iteration terminates without |
85 |
> |
* finding such an entry, <tt>false</tt> is returned. Note that this |
86 |
> |
* implementation requires linear time in the size of the map. |
87 |
|
* |
88 |
< |
* @return <tt>true</tt> if this map maps one or more keys to this value. |
88 |
> |
* @throws NullPointerException {@inheritDoc} |
89 |
> |
* @throws ClassCastException {@inheritDoc} |
90 |
|
*/ |
91 |
|
public boolean containsValue(Object value) { |
92 |
|
Iterator<Entry<K,V>> i = entrySet().iterator(); |
107 |
|
} |
108 |
|
|
109 |
|
/** |
110 |
< |
* Returns <tt>true</tt> if this map contains a mapping for the specified |
111 |
< |
* key. <p> |
110 |
> |
* {@inheritDoc} |
111 |
> |
* |
112 |
> |
* <p>This implementation iterates over <tt>entrySet()</tt> searching |
113 |
> |
* for an entry with the specified key. If such an entry is found, |
114 |
> |
* <tt>true</tt> is returned. If the iteration terminates without |
115 |
> |
* finding such an entry, <tt>false</tt> is returned. Note that this |
116 |
> |
* implementation requires linear time in the size of the map; many |
117 |
> |
* implementations will override this method. |
118 |
|
* |
119 |
< |
* This implementation iterates over <tt>entrySet()</tt> searching for an |
120 |
< |
* entry with the specified key. If such an entry is found, <tt>true</tt> |
126 |
< |
* is returned. If the iteration terminates without finding such an |
127 |
< |
* entry, <tt>false</tt> is returned. Note that this implementation |
128 |
< |
* requires linear time in the size of the map; many implementations will |
129 |
< |
* override this method. |
130 |
< |
* |
131 |
< |
* @param key key whose presence in this map is to be tested. |
132 |
< |
* @return <tt>true</tt> if this map contains a mapping for the specified |
133 |
< |
* key. |
134 |
< |
* @throws NullPointerException if <tt>key</tt> is <tt>null</tt> |
135 |
< |
* and this map does not permit <tt>null</tt> keys. |
119 |
> |
* @throws NullPointerException {@inheritDoc} |
120 |
> |
* @throws ClassCastException {@inheritDoc} |
121 |
|
*/ |
122 |
|
public boolean containsKey(Object key) { |
123 |
|
Iterator<Map.Entry<K,V>> i = entrySet().iterator(); |
138 |
|
} |
139 |
|
|
140 |
|
/** |
141 |
< |
* Returns the value to which this map maps the specified key. Returns |
157 |
< |
* <tt>null</tt> if the map contains no mapping for this key. A return |
158 |
< |
* value of <tt>null</tt> does not <i>necessarily</i> indicate that the |
159 |
< |
* map contains no mapping for the key; it's also possible that the map |
160 |
< |
* explicitly maps the key to <tt>null</tt>. The containsKey operation |
161 |
< |
* may be used to distinguish these two cases. <p> |
162 |
< |
* |
163 |
< |
* This implementation iterates over <tt>entrySet()</tt> searching for an |
164 |
< |
* entry with the specified key. If such an entry is found, the entry's |
165 |
< |
* value is returned. If the iteration terminates without finding such an |
166 |
< |
* entry, <tt>null</tt> is returned. Note that this implementation |
167 |
< |
* requires linear time in the size of the map; many implementations will |
168 |
< |
* override this method. |
141 |
> |
* {@inheritDoc} |
142 |
|
* |
143 |
< |
* @param key key whose associated value is to be returned. |
144 |
< |
* @return the value to which this map maps the specified key. |
143 |
> |
* <p>This implementation iterates over <tt>entrySet()</tt> searching |
144 |
> |
* for an entry with the specified key. If such an entry is found, |
145 |
> |
* the entry's value is returned. If the iteration terminates without |
146 |
> |
* finding such an entry, <tt>null</tt> is returned. Note that this |
147 |
> |
* implementation requires linear time in the size of the map; many |
148 |
> |
* implementations will override this method. |
149 |
|
* |
150 |
< |
* @throws NullPointerException if <tt>key</tt> is <tt>null</tt> |
151 |
< |
* and this map does not permit <tt>null</tt> keys. |
175 |
< |
* |
176 |
< |
* @see #containsKey(Object) |
150 |
> |
* @throws NullPointerException {@inheritDoc} |
151 |
> |
* @throws ClassCastException {@inheritDoc} |
152 |
|
*/ |
153 |
|
public V get(Object key) { |
154 |
|
Iterator<Entry<K,V>> i = entrySet().iterator(); |
172 |
|
// Modification Operations |
173 |
|
|
174 |
|
/** |
175 |
< |
* Associates the specified value with the specified key in this map |
201 |
< |
* (optional operation). If the map previously contained a mapping for |
202 |
< |
* this key, the old value is replaced.<p> |
175 |
> |
* {@inheritDoc} |
176 |
|
* |
177 |
< |
* This implementation always throws an |
177 |
> |
* <p>This implementation always throws an |
178 |
|
* <tt>UnsupportedOperationException</tt>. |
179 |
|
* |
180 |
< |
* @param key key with which the specified value is to be associated. |
181 |
< |
* @param value value to be associated with the specified key. |
182 |
< |
* |
183 |
< |
* @return the previous value associated with specified key, or <tt>null</tt> |
211 |
< |
* if there was no mapping for key. (A <tt>null</tt> return can |
212 |
< |
* also indicate that the map previously associated <tt>null</tt> |
213 |
< |
* with the specified key, if the implementation supports |
214 |
< |
* <tt>null</tt> values.) |
215 |
< |
* |
216 |
< |
* @throws UnsupportedOperationException if the <tt>put</tt> operation |
217 |
< |
* is not supported by this map. |
218 |
< |
* @throws ClassCastException if the class of the specified key or value |
219 |
< |
* prevents it from being stored in this map. |
220 |
< |
* @throws IllegalArgumentException if some aspect of this key or value |
221 |
< |
* prevents it from being stored in this map. |
222 |
< |
* @throws NullPointerException if this map does not permit <tt>null</tt> |
223 |
< |
* keys or values, and the specified key or value is <tt>null</tt>. |
180 |
> |
* @throws UnsupportedOperationException {@inheritDoc} |
181 |
> |
* @throws NullPointerException {@inheritDoc} |
182 |
> |
* @throws ClassCastException {@inheritDoc} |
183 |
> |
* @throws IllegalArgumentException {@inheritDoc} |
184 |
|
*/ |
185 |
|
public V put(K key, V value) { |
186 |
|
throw new UnsupportedOperationException(); |
187 |
|
} |
188 |
|
|
189 |
|
/** |
190 |
< |
* Removes the mapping for this key from this map if present (optional |
231 |
< |
* operation). <p> |
190 |
> |
* {@inheritDoc} |
191 |
|
* |
192 |
< |
* This implementation iterates over <tt>entrySet()</tt> searching for an |
192 |
> |
* <p>This implementation iterates over <tt>entrySet()</tt> searching for an |
193 |
|
* entry with the specified key. If such an entry is found, its value is |
194 |
|
* obtained with its <tt>getValue</tt> operation, the entry is removed |
195 |
|
* from the collection (and the backing map) with the iterator's |
196 |
|
* <tt>remove</tt> operation, and the saved value is returned. If the |
197 |
|
* iteration terminates without finding such an entry, <tt>null</tt> is |
198 |
|
* returned. Note that this implementation requires linear time in the |
199 |
< |
* size of the map; many implementations will override this method.<p> |
199 |
> |
* size of the map; many implementations will override this method. |
200 |
> |
* |
201 |
> |
* <p>Note that this implementation throws an |
202 |
> |
* <tt>UnsupportedOperationException</tt> if the <tt>entrySet</tt> |
203 |
> |
* iterator does not support the <tt>remove</tt> method and this map |
204 |
> |
* contains a mapping for the specified key. |
205 |
|
* |
206 |
< |
* Note that this implementation throws an |
207 |
< |
* <tt>UnsupportedOperationException</tt> if the <tt>entrySet</tt> iterator |
208 |
< |
* does not support the <tt>remove</tt> method and this map contains a |
245 |
< |
* mapping for the specified key. |
246 |
< |
* |
247 |
< |
* @param key key whose mapping is to be removed from the map. |
248 |
< |
* @return the previous value associated with specified key, or <tt>null</tt> |
249 |
< |
* if there was no entry for key. (A <tt>null</tt> return can |
250 |
< |
* also indicate that the map previously associated <tt>null</tt> |
251 |
< |
* with the specified key, if the implementation supports |
252 |
< |
* <tt>null</tt> values.) |
253 |
< |
* @throws UnsupportedOperationException if the <tt>remove</tt> operation |
254 |
< |
* is not supported by this map. |
206 |
> |
* @throws UnsupportedOperationException {@inheritDoc} |
207 |
> |
* @throws NullPointerException {@inheritDoc} |
208 |
> |
* @throws ClassCastException {@inheritDoc} |
209 |
|
*/ |
210 |
|
public V remove(Object key) { |
211 |
|
Iterator<Entry<K,V>> i = entrySet().iterator(); |
236 |
|
// Bulk Operations |
237 |
|
|
238 |
|
/** |
239 |
< |
* Copies all of the mappings from the specified map to this map |
286 |
< |
* (optional operation). These mappings will replace any mappings that |
287 |
< |
* this map had for any of the keys currently in the specified map.<p> |
239 |
> |
* {@inheritDoc} |
240 |
|
* |
241 |
< |
* This implementation iterates over the specified map's |
241 |
> |
* <p>This implementation iterates over the specified map's |
242 |
|
* <tt>entrySet()</tt> collection, and calls this map's <tt>put</tt> |
243 |
< |
* operation once for each entry returned by the iteration.<p> |
243 |
> |
* operation once for each entry returned by the iteration. |
244 |
|
* |
245 |
< |
* Note that this implementation throws an |
245 |
> |
* <p>Note that this implementation throws an |
246 |
|
* <tt>UnsupportedOperationException</tt> if this map does not support |
247 |
|
* the <tt>put</tt> operation and the specified map is nonempty. |
248 |
|
* |
249 |
< |
* @param t mappings to be stored in this map. |
250 |
< |
* |
251 |
< |
* @throws UnsupportedOperationException if the <tt>putAll</tt> operation |
252 |
< |
* is not supported by this map. |
301 |
< |
* @throws ClassCastException if the class of a key or value in the |
302 |
< |
* specified map prevents it from being stored in this map. |
303 |
< |
* @throws IllegalArgumentException if some aspect of a key or value in |
304 |
< |
* the specified map prevents it from being stored in this map. |
305 |
< |
* @throws NullPointerException if the specified map is <tt>null</tt>, or if |
306 |
< |
* this map does not permit <tt>null</tt> keys or values, and the |
307 |
< |
* specified map contains <tt>null</tt> keys or values. |
249 |
> |
* @throws UnsupportedOperationException {@inheritDoc} |
250 |
> |
* @throws NullPointerException {@inheritDoc} |
251 |
> |
* @throws ClassCastException {@inheritDoc} |
252 |
> |
* @throws IllegalArgumentException {@inheritDoc} |
253 |
|
*/ |
254 |
< |
public void putAll(Map<? extends K, ? extends V> t) { |
255 |
< |
Iterator<? extends Entry<? extends K, ? extends V>> i = t.entrySet().iterator(); |
254 |
> |
public void putAll(Map<? extends K, ? extends V> m) { |
255 |
> |
Iterator<? extends Entry<? extends K, ? extends V>> i = m.entrySet().iterator(); |
256 |
|
while (i.hasNext()) { |
257 |
|
Entry<? extends K, ? extends V> e = i.next(); |
258 |
|
put(e.getKey(), e.getValue()); |
260 |
|
} |
261 |
|
|
262 |
|
/** |
263 |
< |
* Removes all mappings from this map (optional operation). <p> |
263 |
> |
* {@inheritDoc} |
264 |
|
* |
265 |
< |
* This implementation calls <tt>entrySet().clear()</tt>. |
265 |
> |
* <p>This implementation calls <tt>entrySet().clear()</tt>. |
266 |
|
* |
267 |
< |
* Note that this implementation throws an |
267 |
> |
* <p>Note that this implementation throws an |
268 |
|
* <tt>UnsupportedOperationException</tt> if the <tt>entrySet</tt> |
269 |
|
* does not support the <tt>clear</tt> operation. |
270 |
|
* |
271 |
< |
* @throws UnsupportedOperationException if the <tt>clear</tt> operation |
327 |
< |
* is not supported by this map. |
271 |
> |
* @throws UnsupportedOperationException {@inheritDoc} |
272 |
|
*/ |
273 |
|
public void clear() { |
274 |
|
entrySet().clear(); |
286 |
|
transient volatile Collection<V> values = null; |
287 |
|
|
288 |
|
/** |
289 |
< |
* Returns a {@link Set} view of the keys contained in this map. |
346 |
< |
* The set is backed by the map, so changes to the map are |
347 |
< |
* reflected in the set, and vice-versa. If the map is modified |
348 |
< |
* while an iteration over the set is in progress (except through |
349 |
< |
* the iterator's own <tt>remove</tt> operation), the results of |
350 |
< |
* the iteration are undefined. The set supports element removal, |
351 |
< |
* which removes the corresponding mapping from the map, via the |
352 |
< |
* <tt>Iterator.remove</tt>, <tt>Set.remove</tt>, |
353 |
< |
* <tt>removeAll</tt> <tt>retainAll</tt>, and <tt>clear</tt> |
354 |
< |
* operations. It does not support the add or <tt>addAll</tt> |
355 |
< |
* operations. |
289 |
> |
* {@inheritDoc} |
290 |
|
* |
291 |
|
* <p>This implementation returns a set that subclasses {@link AbstractSet}. |
292 |
|
* The subclass's iterator method returns a "wrapper object" over this |
334 |
|
} |
335 |
|
|
336 |
|
/** |
337 |
< |
* Returns a {@link Collection} view of the values contained in this map. |
404 |
< |
* The collection is backed by the map, so changes to the map are |
405 |
< |
* reflected in the collection, and vice-versa. If the map is |
406 |
< |
* modified while an iteration over the collection is in progress |
407 |
< |
* (except through the iterator's own <tt>remove</tt> operation), |
408 |
< |
* the results of the iteration are undefined. The collection |
409 |
< |
* supports element removal, which removes the corresponding |
410 |
< |
* mapping from the map, via the <tt>Iterator.remove</tt>, |
411 |
< |
* <tt>Collection.remove</tt>, <tt>removeAll</tt>, |
412 |
< |
* <tt>retainAll</tt> and <tt>clear</tt> operations. It does not |
413 |
< |
* support the add or <tt>addAll</tt> operations. |
337 |
> |
* {@inheritDoc} |
338 |
|
* |
339 |
|
* <p>This implementation returns a collection that subclasses {@link |
340 |
|
* AbstractCollection}. The subclass's iterator method returns a |
347 |
|
* returned in response to all subsequent calls. No synchronization is |
348 |
|
* performed, so there is a slight chance that multiple calls to this |
349 |
|
* method will not all return the same collection. |
426 |
– |
* |
427 |
– |
* @return a collection view of the values contained in this map. |
350 |
|
*/ |
351 |
|
public Collection<V> values() { |
352 |
|
if (values == null) { |
387 |
|
// Comparison and hashing |
388 |
|
|
389 |
|
/** |
390 |
< |
* Compares the specified object with this map for equality. Returns |
469 |
< |
* <tt>true</tt> if the given object is also a map and the two maps |
470 |
< |
* represent the same mappings. More formally, two maps <tt>t1</tt> and |
471 |
< |
* <tt>t2</tt> represent the same mappings if |
472 |
< |
* <tt>t1.keySet().equals(t2.keySet())</tt> and for every key <tt>k</tt> |
473 |
< |
* in <tt>t1.keySet()</tt>, <tt> (t1.get(k)==null ? t2.get(k)==null : |
474 |
< |
* t1.get(k).equals(t2.get(k))) </tt>. This ensures that the |
475 |
< |
* <tt>equals</tt> method works properly across different implementations |
476 |
< |
* of the map interface.<p> |
390 |
> |
* {@inheritDoc} |
391 |
|
* |
392 |
< |
* This implementation first checks if the specified object is this map; |
392 |
> |
* <p>This implementation first checks if the specified object is this map; |
393 |
|
* if so it returns <tt>true</tt>. Then, it checks if the specified |
394 |
|
* object is a map whose size is identical to the size of this map; if |
395 |
|
* not, it returns <tt>false</tt>. If so, it iterates over this map's |
397 |
|
* contains each mapping that this map contains. If the specified map |
398 |
|
* fails to contain such a mapping, <tt>false</tt> is returned. If the |
399 |
|
* iteration completes, <tt>true</tt> is returned. |
486 |
– |
* |
487 |
– |
* @param o object to be compared for equality with this map. |
488 |
– |
* @return <tt>true</tt> if the specified object is equal to this map. |
400 |
|
*/ |
401 |
|
public boolean equals(Object o) { |
402 |
|
if (o == this) |
432 |
|
} |
433 |
|
|
434 |
|
/** |
435 |
< |
* Returns the hash code value for this map. The hash code of a map is |
436 |
< |
* defined to be the sum of the hash codes of each entry in the map's |
437 |
< |
* <tt>entrySet()</tt> view. This ensures that <tt>t1.equals(t2)</tt> |
438 |
< |
* implies that <tt>t1.hashCode()==t2.hashCode()</tt> for any two maps |
439 |
< |
* <tt>t1</tt> and <tt>t2</tt>, as required by the general contract of |
529 |
< |
* Object.hashCode.<p> |
530 |
< |
* |
531 |
< |
* This implementation iterates over <tt>entrySet()</tt>, calling |
532 |
< |
* <tt>hashCode</tt> on each element (entry) in the Collection, and adding |
533 |
< |
* up the results. |
435 |
> |
* {@inheritDoc} |
436 |
> |
* |
437 |
> |
* <p>This implementation iterates over <tt>entrySet()</tt>, calling |
438 |
> |
* <tt>hashCode()</tt> on each element (entry) in the set, and |
439 |
> |
* adding up the results. |
440 |
|
* |
535 |
– |
* @return the hash code value for this map. |
441 |
|
* @see Map.Entry#hashCode() |
442 |
|
* @see Object#hashCode() |
443 |
|
* @see Object#equals(Object) |
502 |
|
* Returns a shallow copy of this <tt>AbstractMap</tt> instance: the keys |
503 |
|
* and values themselves are not cloned. |
504 |
|
* |
505 |
< |
* @return a shallow copy of this map. |
505 |
> |
* @return a shallow copy of this map |
506 |
|
*/ |
507 |
|
protected Object clone() throws CloneNotSupportedException { |
508 |
|
AbstractMap<K,V> result = (AbstractMap<K,V>)super.clone(); |
565 |
|
/** |
566 |
|
* Returns the key corresponding to this entry. |
567 |
|
* |
568 |
< |
* @return the key corresponding to this entry. |
568 |
> |
* @return the key corresponding to this entry |
569 |
|
*/ |
570 |
|
public K getKey() { |
571 |
|
return key; |
574 |
|
/** |
575 |
|
* Returns the value corresponding to this entry. |
576 |
|
* |
577 |
< |
* @return the value corresponding to this entry. |
577 |
> |
* @return the value corresponding to this entry |
578 |
|
*/ |
579 |
|
public V getValue() { |
580 |
|
return value; |
584 |
|
* Replaces the value corresponding to this entry with the specified |
585 |
|
* value. |
586 |
|
* |
587 |
< |
* @param value new value to be stored in this entry. |
588 |
< |
* @return the old value corresponding to the entry. |
587 |
> |
* @param value new value to be stored in this entry |
588 |
> |
* @return the old value corresponding to the entry |
589 |
|
*/ |
590 |
|
public V setValue(V value) { |
591 |
|
V oldValue = this.value; |
611 |
|
* entry's key followed by the equals character ("<tt>=</tt>") |
612 |
|
* followed by the string representation of this entry's value. |
613 |
|
* |
614 |
< |
* @return a String representation of this map entry. |
614 |
> |
* @return a String representation of this map entry |
615 |
|
*/ |
616 |
|
public String toString() { |
617 |
|
return key + "=" + value; |
645 |
|
* Creates an entry representing the same mapping as the |
646 |
|
* specified entry. |
647 |
|
* |
648 |
< |
* @param entry the entry to copy. |
648 |
> |
* @param entry the entry to copy |
649 |
|
*/ |
650 |
|
public SimpleImmutableEntry(Entry<? extends K, ? extends V> entry) { |
651 |
|
this.key = entry.getKey(); |
655 |
|
/** |
656 |
|
* Returns the key corresponding to this entry. |
657 |
|
* |
658 |
< |
* @return the key corresponding to this entry. |
658 |
> |
* @return the key corresponding to this entry |
659 |
|
*/ |
660 |
|
public K getKey() { |
661 |
|
return key; |
664 |
|
/** |
665 |
|
* Returns the value corresponding to this entry. |
666 |
|
* |
667 |
< |
* @return the value corresponding to this entry. |
667 |
> |
* @return the value corresponding to this entry |
668 |
|
*/ |
669 |
|
public V getValue() { |
670 |
|
return value; |
676 |
|
* <tt>UnsupportedOperationException</tt>, as this class implements |
677 |
|
* an <i>immutable</i> map entry. |
678 |
|
* |
679 |
< |
* @param value new value to be stored in this entry. |
679 |
> |
* @param value new value to be stored in this entry |
680 |
|
* @return (Does not return) |
681 |
|
* @throws UnsupportedOperationException always |
682 |
|
*/ |
702 |
|
* entry's key followed by the equals character ("<tt>=</tt>") |
703 |
|
* followed by the string representation of this entry's value. |
704 |
|
* |
705 |
< |
* @return a String representation of this map entry. |
705 |
> |
* @return a String representation of this map entry |
706 |
|
*/ |
707 |
|
public String toString() { |
708 |
|
return key + "=" + value; |