Class DefaultEntry<K,​V>

  • Type Parameters:
    K - the type of the key
    V - the type of the value
    All Implemented Interfaces:
    java.util.Map.Entry<K,​V>
    Direct Known Subclasses:
    ImmutableEntry

    public class DefaultEntry<K,​V>
    extends java.lang.Object
    implements java.util.Map.Entry<K,​V>
    A default implementation of the Map.Entry interface, representing a key-value pair. This class provides an immutable key and a mutable value, allowing for updates to the value while keeping the same key. It is suitable for use in custom map implementations or other scenarios where a modifiable entry needs to be maintained.
    Since:
    1.0.0
    Author:
    Mercy
    See Also:
    Map.Entry
    • Constructor Detail

      • DefaultEntry

        public DefaultEntry​(K key,
                            V value)
    • Method Detail

      • getKey

        public final K getKey()
        Specified by:
        getKey in interface java.util.Map.Entry<K,​V>
      • getValue

        public final V getValue()
        Specified by:
        getValue in interface java.util.Map.Entry<K,​V>
      • setValue

        public V setValue​(V value)
        Specified by:
        setValue in interface java.util.Map.Entry<K,​V>
      • equals

        public boolean equals​(java.lang.Object o)
        Specified by:
        equals in interface java.util.Map.Entry<K,​V>
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Specified by:
        hashCode in interface java.util.Map.Entry<K,​V>
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • of

        public static <K,​V> DefaultEntry<K,​V> of​(K key,
                                                             V value)
        Create a new instance of DefaultEntry with the specified key and value.
        Type Parameters:
        K - the type of the key
        V - the type of the value
        Parameters:
        key - the key
        value - the value
        Returns:
        a new instance of DefaultEntry