587 // are distinct unrelated classes, even though they share
588 // some code. Since you can't add or subtract final-ness
589 // of a field in a subclass, they can't share representations,
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 private static final long serialVersionUID = -8499721149061103585L;
608
609 private final K key;
610 private V value;
611
612 /**
613 * Creates an entry representing a mapping from the specified
614 * key to the specified value.
615 *
616 * @param key the key represented by this entry
617 * @param value the value represented by this entry
618 */
619 public SimpleEntry(K key, V value) {
620 this.key = key;
621 this.value = value;
622 }
623
624 /**
625 * Creates an entry representing the same mapping as the
626 * specified entry.
717 *
718 * @return a String representation of this map entry
719 */
720 public String toString() {
721 return key + "=" + value;
722 }
723
724 }
725
726 /**
727 * An Entry maintaining an immutable key and value. This class
728 * does not support method {@code setValue}. This class may be
729 * convenient in methods that return thread-safe snapshots of
730 * key-value mappings.
731 *
732 * @since 1.6
733 */
734 public static class SimpleImmutableEntry<K,V>
735 implements Entry<K,V>, java.io.Serializable
736 {
737 private static final long serialVersionUID = 7138329143949025153L;
738
739 private final K key;
740 private final V value;
741
742 /**
743 * Creates an entry representing a mapping from the specified
744 * key to the specified value.
745 *
746 * @param key the key represented by this entry
747 * @param value the value represented by this entry
748 */
749 public SimpleImmutableEntry(K key, V value) {
750 this.key = key;
751 this.value = value;
752 }
753
754 /**
755 * Creates an entry representing the same mapping as the
756 * specified entry.
|
587 // are distinct unrelated classes, even though they share
588 // some code. Since you can't add or subtract final-ness
589 // of a field in a subclass, they can't share representations,
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.
718 *
719 * @return a String representation of this map entry
720 */
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.
|