Class DefaultKeyValue

  • All Implemented Interfaces:
    KeyValue

    @Deprecated(since="2021-04-30")
    public class DefaultKeyValue
    extends AbstractKeyValue
    Deprecated.
    Commons Collections 3 is in maintenance mode. Commons Collections 4 should be used instead.
    A mutable KeyValue pair that does not implement Map.Entry.

    Note that a DefaultKeyValue instance may not contain itself as a key or value.

    Since:
    Commons Collections 3.0
    • Constructor Detail

      • DefaultKeyValue

        public DefaultKeyValue()
        Deprecated.
        Constructs a new pair with a null key and null value.
      • DefaultKeyValue

        public DefaultKeyValue​(Object key,
                               Object value)
        Deprecated.
        Constructs a new pair with the specified key and given value.
        Parameters:
        key - the key for the entry, may be null
        value - the value for the entry, may be null
      • DefaultKeyValue

        public DefaultKeyValue​(KeyValue pair)
        Deprecated.
        Constructs a new pair from the specified KeyValue.
        Parameters:
        pair - the pair to copy, must not be null
        Throws:
        NullPointerException - if the entry is null
      • DefaultKeyValue

        public DefaultKeyValue​(Map.Entry entry)
        Deprecated.
        Constructs a new pair from the specified Map.Entry.
        Parameters:
        entry - the entry to copy, must not be null
        Throws:
        NullPointerException - if the entry is null
    • Method Detail

      • setKey

        public Object setKey​(Object key)
        Deprecated.
        Sets the key.
        Parameters:
        key - the new key
        Returns:
        the old key
        Throws:
        IllegalArgumentException - if key is this object
      • setValue

        public Object setValue​(Object value)
        Deprecated.
        Sets the value.
        Parameters:
        value - the new value
        Returns:
        the old value of the value
        Throws:
        IllegalArgumentException - if value is this object
      • toMapEntry

        public Map.Entry toMapEntry()
        Deprecated.
        Returns a new Map.Entry object with key and value from this pair.
        Returns:
        a MapEntry instance
      • equals

        public boolean equals​(Object obj)
        Deprecated.
        Compares this Map.Entry with another Map.Entry.

        Returns true if the compared object is also a DefaultKeyValue, and its key and value are equal to this object's key and value.

        Overrides:
        equals in class Object
        Parameters:
        obj - the object to compare to
        Returns:
        true if equal key and value
      • hashCode

        public int hashCode()
        Deprecated.
        Gets a hashCode compatible with the equals method.

        Implemented per API documentation of Map.Entry.hashCode(), however subclasses may override this.

        Overrides:
        hashCode in class Object
        Returns:
        a suitable hash code