Class Entry<K,V>

java.lang.Object
me.sbasalaev.collection.Entry<K,V>
Type Parameters:
K - type of the key.
V - type of the value.

public abstract class Entry<@Out K,@Out V> extends Object
Map entry. Associates key with value.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructor for subclasses.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Whether given object is equal to this entry.
    int
    The hash code for this entry.
    abstract K
    key()
    The key of this entry.
    int
    Returns the hash code of the key.
    static <K, V> Entry<K,V>
    of(K key, V value)
    Returns map entry with given key and value.
    String representation of this entry.
    abstract V
    The value associated with the key in this entry.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Entry

      public Entry()
      Constructor for subclasses.
  • Method Details

    • of

      public static <K, V> Entry<K,V> of(K key, V value)
      Returns map entry with given key and value. The entry is immutable and caches key hash.
    • key

      public abstract K key()
      The key of this entry.
    • value

      public abstract V value()
      The value associated with the key in this entry.
    • keyHash

      public int keyHash()
      Returns the hash code of the key. May be overriden if caching the hash is desired.
    • equals

      public boolean equals(@Nullable Object obj)
      Whether given object is equal to this entry. Two entries are equal if they contain the same keys and values.
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      The hash code for this entry.
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      String representation of this entry. Returns string of the form
      key => value
      Overrides:
      toString in class Object