531 |
|
* Test for equality, checking for nulls. |
532 |
|
*/ |
533 |
|
private static boolean eq(Object o1, Object o2) { |
534 |
< |
return (o1 == null ? o2 == null : o1.equals(o2)); |
534 |
> |
return o1 == null ? o2 == null : o1.equals(o2); |
535 |
|
} |
536 |
|
|
537 |
|
// Implementation Note: SimpleEntry and SimpleImmutableEntry |
548 |
|
* facilitates the process of building custom map |
549 |
|
* implementations. For example, it may be convenient to return |
550 |
|
* arrays of <tt>SimpleEntry</tt> instances in method |
551 |
< |
* <tt>Map.entrySet().toArray</tt> |
551 |
> |
* <tt>Map.entrySet().toArray</tt>. |
552 |
|
* |
553 |
|
* @since 1.6 |
554 |
|
*/ |
555 |
< |
public static class SimpleEntry<K,V> implements Entry<K,V> { |
555 |
> |
public static class SimpleEntry<K,V> |
556 |
> |
implements Entry<K,V>, java.io.Serializable |
557 |
> |
{ |
558 |
> |
private static final long serialVersionUID = -8499721149061103585L; |
559 |
> |
|
560 |
|
private final K key; |
561 |
|
private V value; |
562 |
|
|
622 |
|
} |
623 |
|
|
624 |
|
public int hashCode() { |
625 |
< |
return ((key == null) ? 0 : key.hashCode()) ^ |
626 |
< |
((value == null) ? 0 : value.hashCode()); |
625 |
> |
return (key == null ? 0 : key.hashCode()) ^ |
626 |
> |
(value == null ? 0 : value.hashCode()); |
627 |
|
} |
628 |
|
|
629 |
|
/** |
641 |
|
} |
642 |
|
|
643 |
|
/** |
644 |
< |
* An Entry maintaining an immutable key and value, This class |
644 |
> |
* An Entry maintaining an immutable key and value. This class |
645 |
|
* does not support method <tt>setValue</tt>. This class may be |
646 |
|
* convenient in methods that return thread-safe snapshots of |
647 |
|
* key-value mappings. |
648 |
|
* |
649 |
|
* @since 1.6 |
650 |
|
*/ |
651 |
< |
public static class SimpleImmutableEntry<K,V> implements Entry<K,V> { |
651 |
> |
public static class SimpleImmutableEntry<K,V> |
652 |
> |
implements Entry<K,V>, java.io.Serializable |
653 |
> |
{ |
654 |
> |
private static final long serialVersionUID = 7138329143949025153L; |
655 |
> |
|
656 |
|
private final K key; |
657 |
|
private final V value; |
658 |
|
|
719 |
|
} |
720 |
|
|
721 |
|
public int hashCode() { |
722 |
< |
return ((key == null) ? 0 : key.hashCode()) ^ |
723 |
< |
((value == null) ? 0 : value.hashCode()); |
722 |
> |
return (key == null ? 0 : key.hashCode()) ^ |
723 |
> |
(value == null ? 0 : value.hashCode()); |
724 |
|
} |
725 |
|
|
726 |
|
/** |