ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/main/java/util/AbstractMap.java
(Generate patch)

Comparing jsr166/src/main/java/util/AbstractMap.java (file contents):
Revision 1.2 by dl, Sun Mar 6 12:06:17 2005 UTC vs.
Revision 1.9 by jsr166, Sat May 14 01:52:24 2005 UTC

# Line 1 | Line 1
1   /*
2   * %W% %E%
3   *
4 < * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
4 > * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
5   * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6   */
7  
# Line 10 | Line 10 | import java.util.Map.Entry;
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   *
40 + * @param <K> the type of keys maintained by this map
41 + * @param <V> the type of mapped values
42 + *
43   * @author  Josh Bloch
44   * @author  Neal Gafter
45   * @version %I%, %G%
# Line 56 | Line 59 | public abstract class AbstractMap<K,V> i
59      // Query Operations
60  
61      /**
62 <     * Returns the number of key-value mappings in this map.  If the map
60 <     * contains more than <tt>Integer.MAX_VALUE</tt> elements, returns
61 <     * <tt>Integer.MAX_VALUE</tt>.<p>
62 <     *
63 <     * This implementation returns <tt>entrySet().size()</tt>.
62 >     * {@inheritDoc}
63       *
64 <     * @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>
73 <     *
74 <     * 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.
81 <     * More formally, returns <tt>true</tt> if and only if this map contains
82 <     * at least one mapping to a value <tt>v</tt> such that <tt>(value==null ?
83 <     * v==null : value.equals(v))</tt>.  This operation will probably require
84 <     * time linear in the map size for most implementations of map.<p>
85 <     *
86 <     * This implementation iterates over entrySet() searching for an entry
87 <     * with the specified value.  If such an entry is found, <tt>true</tt> is
88 <     * returned.  If the iteration terminates without finding such an entry,
89 <     * <tt>false</tt> is returned.  Note that this implementation requires
93 <     * linear time in the size of the map.
94 <     *
95 <     * @param value value whose presence in this map is to be tested.
96 <     *
97 <     * @return <tt>true</tt> if this map maps one or more keys to this value.
80 >     * {@inheritDoc}
81 >     *
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 >     * @throws NullPointerException {@inheritDoc}
89 >     * @throws ClassCastException   {@inheritDoc}
90       */
91      public boolean containsValue(Object value) {
92          Iterator<Entry<K,V>> i = entrySet().iterator();
# Line 115 | Line 107 | public abstract class AbstractMap<K,V> i
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>
123 <     * is returned.  If the iteration terminates without finding such an
124 <     * entry, <tt>false</tt> is returned.  Note that this implementation
125 <     * requires linear time in the size of the map; many implementations will
126 <     * override this method.
127 <     *
128 <     * @param key key whose presence in this map is to be tested.
129 <     * @return <tt>true</tt> if this map contains a mapping for the specified
130 <     *            key.
131 <     *
132 <     * @throws NullPointerException if the key is <tt>null</tt> and this map
133 <     *            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();
# Line 151 | Line 138 | public abstract class AbstractMap<K,V> i
138      }
139  
140      /**
141 <     * Returns the value to which this map maps the specified key.  Returns
142 <     * <tt>null</tt> if the map contains no mapping for this key.  A return
143 <     * value of <tt>null</tt> does not <i>necessarily</i> indicate that the
144 <     * map contains no mapping for the key; it's also possible that the map
145 <     * explicitly maps the key to <tt>null</tt>.  The containsKey operation
146 <     * may be used to distinguish these two cases. <p>
147 <     *
148 <     * This implementation iterates over <tt>entrySet()</tt> searching for an
149 <     * entry with the specified key.  If such an entry is found, the entry's
150 <     * value is returned.  If the iteration terminates without finding such an
151 <     * entry, <tt>null</tt> is returned.  Note that this implementation
165 <     * requires linear time in the size of the map; many implementations will
166 <     * override this method.
167 <     *
168 <     * @param key key whose associated value is to be returned.
169 <     * @return the value to which this map maps the specified key.
170 <     *
171 <     * @throws NullPointerException if the key is <tt>null</tt> and this map
172 <     *            does not permit <tt>null</tt> keys.
173 <     *
174 <     * @see #containsKey(Object)
141 >     * {@inheritDoc}
142 >     *
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          {@inheritDoc}
151 >     * @throws ClassCastException            {@inheritDoc}
152       */
153      public V get(Object key) {
154          Iterator<Entry<K,V>> i = entrySet().iterator();
# Line 195 | Line 172 | public abstract class AbstractMap<K,V> i
172      // Modification Operations
173  
174      /**
175 <     * Associates the specified value with the specified key in this map
199 <     * (optional operation).  If the map previously contained a mapping for
200 <     * 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 previous value associated with specified key, or <tt>null</tt>
209 <     *         if there was no mapping for key.  (A <tt>null</tt> return can
210 <     *         also indicate that the map previously associated <tt>null</tt>
211 <     *         with the specified key, if the implementation supports
212 <     *         <tt>null</tt> values.)
213 <     *
214 <     * @throws UnsupportedOperationException if the <tt>put</tt> operation is
215 <     *            not supported by this map.
216 <     *
217 <     * @throws ClassCastException if the class of the specified key or value
218 <     *            prevents it from being stored in this map.
219 <     *
220 <     * @throws IllegalArgumentException if some aspect of this key or value *
221 <     *            prevents it from being stored in this map.
222 <     *
223 <     * @throws NullPointerException if this map does not permit <tt>null</tt>
224 <     *            keys or values, and the specified key or value is
225 <     *            <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
233 <     * 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
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 <     * Note that this implementation throws an
202 <     * <tt>UnsupportedOperationException</tt> if the <tt>entrySet</tt> iterator
203 <     * does not support the <tt>remove</tt> method and this map contains a
204 <     * mapping for the specified key.
205 <     *
206 <     * @param key key whose mapping is to be removed from the map.
207 <     * @return previous value associated with specified key, or <tt>null</tt>
208 <     *         if there was no entry for key.  (A <tt>null</tt> return can
252 <     *         also indicate that the map previously associated <tt>null</tt>
253 <     *         with the specified key, if the implementation supports
254 <     *         <tt>null</tt> values.)
255 <     * @throws UnsupportedOperationException if the <tt>remove</tt> operation
256 <     *            is not supported by this map.
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 >     * @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();
# Line 284 | Line 236 | public abstract class AbstractMap<K,V> i
236      // Bulk Operations
237  
238      /**
239 <     * Copies all of the mappings from the specified map to this map
288 <     * (optional operation).  These mappings will replace any mappings that
289 <     * 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.
303 <     *
304 <     * @throws ClassCastException if the class of a key or value in the
305 <     *            specified map prevents it from being stored in this map.
306 <     *
307 <     * @throws IllegalArgumentException if some aspect of a key or value in
308 <     *            the specified map prevents it from being stored in this map.
309 <     * @throws NullPointerException if the specified map is <tt>null</tt>, or if
310 <     *         this map does not permit <tt>null</tt> keys or values, and the
311 <     *         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());
# Line 319 | Line 260 | public abstract class AbstractMap<K,V> i
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 clear is not supported
331 <     *            by this map.
271 >     * @throws UnsupportedOperationException {@inheritDoc}
272       */
273      public void clear() {
274          entrySet().clear();
# Line 346 | Line 286 | public abstract class AbstractMap<K,V> i
286      transient volatile Collection<V> values = null;
287  
288      /**
289 <     * Returns a Set view of the keys contained in this map.  The Set is
290 <     * backed by the map, so changes to the map are reflected in the Set,
291 <     * and vice-versa.  (If the map is modified while an iteration over
292 <     * the Set is in progress, the results of the iteration are undefined.)
293 <     * The Set supports element removal, which removes the corresponding entry
294 <     * from the map, via the Iterator.remove, Set.remove,  removeAll
295 <     * retainAll, and clear operations.  It does not support the add or
296 <     * addAll operations.<p>
357 <     *
358 <     * This implementation returns a Set that subclasses
359 <     * AbstractSet.  The subclass's iterator method returns a "wrapper
360 <     * object" over this map's entrySet() iterator.  The size method delegates
361 <     * to this map's size method and the contains method delegates to this
362 <     * map's containsKey method.<p>
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
293 >     * map's <tt>entrySet()</tt> iterator.  The <tt>size</tt> method
294 >     * delegates to this map's <tt>size</tt> method and the
295 >     * <tt>contains</tt> method delegates to this map's
296 >     * <tt>containsKey</tt> method.
297       *
298 <     * The Set is created the first time this method is called,
298 >     * <p>The set is created the first time this method is called,
299       * and returned in response to all subsequent calls.  No synchronization
300       * is performed, so there is a slight chance that multiple calls to this
301 <     * method will not all return the same Set.
368 <     *
369 <     * @return a Set view of the keys contained in this map.
301 >     * method will not all return the same set.
302       */
303      public Set<K> keySet() {
304          if (keySet == null) {
# Line 402 | Line 334 | public abstract class AbstractMap<K,V> i
334      }
335  
336      /**
337 <     * Returns a collection view of the values contained in this map.  The
338 <     * collection is backed by the map, so changes to the map are reflected in
339 <     * the collection, and vice-versa.  (If the map is modified while an
340 <     * iteration over the collection is in progress, the results of the
341 <     * iteration are undefined.)  The collection supports element removal,
342 <     * which removes the corresponding entry from the map, via the
343 <     * <tt>Iterator.remove</tt>, <tt>Collection.remove</tt>,
344 <     * <tt>removeAll</tt>, <tt>retainAll</tt> and <tt>clear</tt> operations.
413 <     * It does not support the <tt>add</tt> or <tt>addAll</tt> operations.<p>
414 <     *
415 <     * This implementation returns a collection that subclasses abstract
416 <     * collection.  The subclass's iterator method returns a "wrapper object"
417 <     * over this map's <tt>entrySet()</tt> iterator.  The size method
418 <     * delegates to this map's size method and the contains method delegates
419 <     * to this map's containsValue method.<p>
337 >     * {@inheritDoc}
338 >     *
339 >     * <p>This implementation returns a collection that subclasses {@link
340 >     * AbstractCollection}.  The subclass's iterator method returns a
341 >     * "wrapper object" over this map's <tt>entrySet()</tt> iterator.
342 >     * The <tt>size</tt> method delegates to this map's <tt>size</tt>
343 >     * method and the <tt>contains</tt> method delegates to this map's
344 >     * <tt>containsValue</tt> method.
345       *
346 <     * The collection is created the first time this method is called, and
346 >     * <p>The collection is created the first time this method is called, and
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.
425 <     *
426 <     * @return a collection view of the values contained in this map.
349 >     * method will not all return the same collection.
350       */
351      public Collection<V> values() {
352          if (values == null) {
# Line 458 | Line 381 | public abstract class AbstractMap<K,V> i
381          return values;
382      }
383  
461    /**
462     * Returns a set view of the mappings contained in this map.  Each element
463     * in this set is a Map.Entry.  The set is backed by the map, so changes
464     * to the map are reflected in the set, and vice-versa.  (If the map is
465     * modified while an iteration over the set is in progress, the results of
466     * the iteration are undefined.)  The set supports element removal, which
467     * removes the corresponding entry from the map, via the
468     * <tt>Iterator.remove</tt>, <tt>Set.remove</tt>, <tt>removeAll</tt>,
469     * <tt>retainAll</tt> and <tt>clear</tt> operations.  It does not support
470     * the <tt>add</tt> or <tt>addAll</tt> operations.
471     *
472     * @return a set view of the mappings contained in this map.
473     */
384      public abstract Set<Entry<K,V>> entrySet();
385  
386  
387      // Comparison and hashing
388  
389      /**
390 <     * Compares the specified object with this map for equality.  Returns
481 <     * <tt>true</tt> if the given object is also a map and the two maps
482 <     * represent the same mappings.  More formally, two maps <tt>t1</tt> and
483 <     * <tt>t2</tt> represent the same mappings if
484 <     * <tt>t1.keySet().equals(t2.keySet())</tt> and for every key <tt>k</tt>
485 <     * in <tt>t1.keySet()</tt>, <tt> (t1.get(k)==null ? t2.get(k)==null :
486 <     * t1.get(k).equals(t2.get(k))) </tt>.  This ensures that the
487 <     * <tt>equals</tt> method works properly across different implementations
488 <     * 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 set; if
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
396       * <tt>entrySet</tt> collection, and checks that the specified map
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.
498     *
499     * @param o object to be compared for equality with this map.
500     * @return <tt>true</tt> if the specified object is equal to this map.
400       */
401      public boolean equals(Object o) {
402          if (o == this)
# Line 523 | Line 422 | public abstract class AbstractMap<K,V> i
422                          return false;
423                  }
424              }
425 <        } catch(ClassCastException unused) {
425 >        } catch (ClassCastException unused) {
426              return false;
427 <        } catch(NullPointerException unused) {
427 >        } catch (NullPointerException unused) {
428              return false;
429          }
430  
# Line 533 | Line 432 | public abstract class AbstractMap<K,V> i
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
541 <     * Object.hashCode.<p>
542 <     *
543 <     * This implementation iterates over <tt>entrySet()</tt>, calling
544 <     * <tt>hashCode</tt> on each element (entry) in the Collection, and adding
545 <     * 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       *
547     * @return the hash code value for this map.
441       * @see Map.Entry#hashCode()
442       * @see Object#hashCode()
443       * @see Object#equals(Object)
# Line 604 | Line 497 | public abstract class AbstractMap<K,V> i
497          buf.append("}");
498          return buf.toString();
499      }
500 <    
500 >
501      /**
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();
# Line 629 | Line 522 | public abstract class AbstractMap<K,V> i
522      // Implementation Note: SimpleEntry and SimpleImmutableEntry
523      // are distinct unrelated classes, even though they share
524      // some code. Since you can't add or subtract final-ness
525 <    // of a field in a subclass, they can't share represenations,
525 >    // of a field in a subclass, they can't share representations,
526      // and the amount of duplicated code is too small to warrant
527      // exposing a common abstract class.
528  
# Line 664 | Line 557 | public abstract class AbstractMap<K,V> i
557           *
558           * @param entry the entry to copy.
559           */
560 <        public SimpleEntry(Entry<K,V> entry) {
560 >        public SimpleEntry(Entry<? extends K, ? extends V> entry) {
561              this.key   = entry.getKey();
562              this.value = entry.getValue();
563          }
# Line 672 | Line 565 | public abstract class AbstractMap<K,V> i
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;
# Line 681 | Line 574 | public abstract class AbstractMap<K,V> i
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;
# Line 691 | Line 584 | public abstract class AbstractMap<K,V> i
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 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;
# Line 718 | Line 611 | public abstract class AbstractMap<K,V> i
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;
# Line 752 | Line 645 | public abstract class AbstractMap<K,V> i
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<K,V> entry) {
650 >        public SimpleImmutableEntry(Entry<? extends K, ? extends V> entry) {
651              this.key   = entry.getKey();
652              this.value = entry.getValue();
653          }
# Line 762 | Line 655 | public abstract class AbstractMap<K,V> i
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;
# Line 771 | Line 664 | public abstract class AbstractMap<K,V> i
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;
# Line 783 | Line 676 | public abstract class AbstractMap<K,V> i
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           */
# Line 809 | Line 702 | public abstract class AbstractMap<K,V> i
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;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines