590 // and the amount of duplicated code is too small to warrant 591 // exposing a common abstract class. 592 593 594 /** 595 * An Entry maintaining a key and a value. The value may be 596 * changed using the {@code setValue} method. This class 597 * facilitates the process of building custom map 598 * implementations. For example, it may be convenient to return 599 * arrays of {@code SimpleEntry} instances in method 600 * {@code Map.entrySet().toArray}. 601 * 602 * @since 1.6 603 */ 604 public static class SimpleEntry<K,V> 605 implements Entry<K,V>, java.io.Serializable 606 { 607 @java.io.Serial 608 private static final long serialVersionUID = -8499721149061103585L; 609 610 private final K key; 611 private V value; 612 613 /** 614 * Creates an entry representing a mapping from the specified 615 * key to the specified value. 616 * 617 * @param key the key represented by this entry 618 * @param value the value represented by this entry 619 */ 620 public SimpleEntry(K key, V value) { 621 this.key = key; 622 this.value = value; 623 } 624 625 /** 626 * Creates an entry representing the same mapping as the 627 * specified entry. 628 * 629 * @param entry the entry to copy 630 */ 721 public String toString() { 722 return key + "=" + value; 723 } 724 725 } 726 727 /** 728 * An Entry maintaining an immutable key and value. This class 729 * does not support method {@code setValue}. This class may be 730 * convenient in methods that return thread-safe snapshots of 731 * key-value mappings. 732 * 733 * @since 1.6 734 */ 735 public static class SimpleImmutableEntry<K,V> 736 implements Entry<K,V>, java.io.Serializable 737 { 738 @java.io.Serial 739 private static final long serialVersionUID = 7138329143949025153L; 740 741 private final K key; 742 private final V value; 743 744 /** 745 * Creates an entry representing a mapping from the specified 746 * key to the specified value. 747 * 748 * @param key the key represented by this entry 749 * @param value the value represented by this entry 750 */ 751 public SimpleImmutableEntry(K key, V value) { 752 this.key = key; 753 this.value = value; 754 } 755 756 /** 757 * Creates an entry representing the same mapping as the 758 * specified entry. 759 * 760 * @param entry the entry to copy 761 */ | 590 // and the amount of duplicated code is too small to warrant 591 // exposing a common abstract class. 592 593 594 /** 595 * An Entry maintaining a key and a value. The value may be 596 * changed using the {@code setValue} method. This class 597 * facilitates the process of building custom map 598 * implementations. For example, it may be convenient to return 599 * arrays of {@code SimpleEntry} instances in method 600 * {@code Map.entrySet().toArray}. 601 * 602 * @since 1.6 603 */ 604 public static class SimpleEntry<K,V> 605 implements Entry<K,V>, java.io.Serializable 606 { 607 @java.io.Serial 608 private static final long serialVersionUID = -8499721149061103585L; 609 610 @SuppressWarnings("serial") // Conditionally serializable 611 private final K key; 612 @SuppressWarnings("serial") // Conditionally serializable 613 private V value; 614 615 /** 616 * Creates an entry representing a mapping from the specified 617 * key to the specified value. 618 * 619 * @param key the key represented by this entry 620 * @param value the value represented by this entry 621 */ 622 public SimpleEntry(K key, V value) { 623 this.key = key; 624 this.value = value; 625 } 626 627 /** 628 * Creates an entry representing the same mapping as the 629 * specified entry. 630 * 631 * @param entry the entry to copy 632 */ 723 public String toString() { 724 return key + "=" + value; 725 } 726 727 } 728 729 /** 730 * An Entry maintaining an immutable key and value. This class 731 * does not support method {@code setValue}. This class may be 732 * convenient in methods that return thread-safe snapshots of 733 * key-value mappings. 734 * 735 * @since 1.6 736 */ 737 public static class SimpleImmutableEntry<K,V> 738 implements Entry<K,V>, java.io.Serializable 739 { 740 @java.io.Serial 741 private static final long serialVersionUID = 7138329143949025153L; 742 743 @SuppressWarnings("serial") // Not statically typed as Serializable 744 private final K key; 745 @SuppressWarnings("serial") // Not statically typed as Serializable 746 private final V value; 747 748 /** 749 * Creates an entry representing a mapping from the specified 750 * key to the specified value. 751 * 752 * @param key the key represented by this entry 753 * @param value the value represented by this entry 754 */ 755 public SimpleImmutableEntry(K key, V value) { 756 this.key = key; 757 this.value = value; 758 } 759 760 /** 761 * Creates an entry representing the same mapping as the 762 * specified entry. 763 * 764 * @param entry the entry to copy 765 */ |