类 KeyValueHolder<K,V>

java.lang.Object
cn.taketoday.util.KeyValueHolder<K,V>
类型参数:
K - the key type
V - the value type
所有已实现的接口:
Map.Entry<K,V>

public final class KeyValueHolder<K,V> extends Object implements Map.Entry<K,V>
An immutable container for a key and a value, suitable for use in creating and populating Map instances.
从以下版本开始:
4.0 2022/2/26 23:28
作者:
Harry Yang
  • 字段概要

    字段
    修饰符和类型
    字段
    说明
    private final K
     
    private V
     
  • 构造器概要

    构造器
    构造器
    说明
     
  • 方法概要

    修饰符和类型
    方法
    说明
    boolean
    Compares the specified object with this entry for equality.
    Gets the key from this holder.
    Gets the value from this holder.
    int
    Returns the hash code value for this map entry.
    setValue(V value)
    Replaces the value corresponding to this entry with the specified value (optional operation).
    Returns a String representation of this map entry.

    从类继承的方法 java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • 字段详细资料

    • key

      private final K key
    • value

      @Nullable private V value
  • 构造器详细资料

    • KeyValueHolder

      public KeyValueHolder(K k, @Nullable V v)
  • 方法详细资料

    • getKey

      public K getKey()
      Gets the key from this holder.
      指定者:
      getKey 在接口中 Map.Entry<K,V>
      返回:
      the key
    • getValue

      @Nullable public V getValue()
      Gets the value from this holder.
      指定者:
      getValue 在接口中 Map.Entry<K,V>
      返回:
      the value
    • setValue

      @Nullable public V setValue(V value)
      Replaces the value corresponding to this entry with the specified value (optional operation). (Writes through to the map.) The behavior of this call is undefined if the mapping has already been removed from the map (by the iterator's remove operation).
      指定者:
      setValue 在接口中 Map.Entry<K,V>
      参数:
      value - new value to be stored in this entry
      返回:
      old value corresponding to the entry
      抛出:
      ClassCastException - if the class of the specified value prevents it from being stored in the backing map
    • equals

      public boolean equals(Object o)
      Compares the specified object with this entry for equality. Returns true if the given object is also a map entry and the two entries' keys and values are equal. Note that key and value are non-null, so equals() can be called safely on them.
      指定者:
      equals 在接口中 Map.Entry<K,V>
      覆盖:
      equals 在类中 Object
    • hashCode

      public int hashCode()
      Returns the hash code value for this map entry. The hash code is key.hashCode() ^ value.hashCode(). Note that key and value are non-null, so hashCode() can be called safely on them.
      指定者:
      hashCode 在接口中 Map.Entry<K,V>
      覆盖:
      hashCode 在类中 Object
    • toString

      public String toString()
      Returns a String representation of this map entry. This implementation returns the string representation of this entry's key followed by the equals character ("=") followed by the string representation of this entry's value.
      覆盖:
      toString 在类中 Object
      返回:
      a String representation of this map entry