629 |
|
// Implementation Note: SimpleEntry and SimpleImmutableEntry |
630 |
|
// are distinct unrelated classes, even though they share |
631 |
|
// some code. Since you can't add or subtract final-ness |
632 |
< |
// of a field in a subclass, they can't share represenations, |
632 |
> |
// of a field in a subclass, they can't share representations, |
633 |
|
// and the amount of duplicated code is too small to warrant |
634 |
|
// exposing a common abstract class. |
635 |
|
|
643 |
|
* <tt>Map.entrySet().toArray</tt> |
644 |
|
*/ |
645 |
|
public static class SimpleEntry<K,V> implements Entry<K,V> { |
646 |
< |
private K key; |
646 |
> |
private final K key; |
647 |
|
private V value; |
648 |
|
|
649 |
|
/** |
664 |
|
* |
665 |
|
* @param entry the entry to copy. |
666 |
|
*/ |
667 |
< |
public SimpleEntry(Entry<K,V> entry) { |
667 |
> |
public SimpleEntry(Entry<? extends K, ? extends V> entry) { |
668 |
|
this.key = entry.getKey(); |
669 |
|
this.value = entry.getValue(); |
670 |
|
} |
754 |
|
* |
755 |
|
* @param entry the entry to copy. |
756 |
|
*/ |
757 |
< |
public SimpleImmutableEntry(Entry<K,V> entry) { |
757 |
> |
public SimpleImmutableEntry(Entry<? extends K, ? extends V> entry) { |
758 |
|
this.key = entry.getKey(); |
759 |
|
this.value = entry.getValue(); |
760 |
|
} |