Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.commons.collections.keyvalue
Class DefaultKeyValue

    java.lang.Object
      org.apache.commons.collections.keyvalue.AbstractKeyValue
          org.apache.commons.collections.keyvalue.DefaultKeyValue

All Implemented Interfaces:
  KeyValue

    public class DefaultKeyValue

extends AbstractKeyValue

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
Version:
  $Revision: 646777 $ $Date: 2008-04-10 13:33:15 +0100 (Thu, 10 Apr 2008) $
Author:
  James Strachan, Michael A. Smith, Neil O'Toole, Stephen Colebourne

Field Summary

Fields inherited from class org.apache.commons.collections.keyvalue.AbstractKeyValue
`key, value`

Constructor Summary
`DefaultKeyValue()` Constructs a new pair with a null key and null value.
`DefaultKeyValue(KeyValue pair)` Constructs a new pair from the specified `KeyValue`.
`DefaultKeyValue(java.util.Map.Entry entry)` Constructs a new pair from the specified `Map.Entry`.
`DefaultKeyValue(java.lang.Object key, java.lang.Object value)` Constructs a new pair with the specified key and given value.

Method Summary
`boolean` | `equals(java.lang.Object obj)` Compares this `Map.Entry` with another `Map.Entry`.
`int` | `hashCode()` Gets a hashCode compatible with the equals method.
`java.lang.Object` | `setKey(java.lang.Object key)` Sets the key.
`java.lang.Object` | `setValue(java.lang.Object value)` Sets the value.
`java.util.Map.Entry` | `toMapEntry()` Returns a new `Map.Entry` object with key and value from this pair.

Methods inherited from class org.apache.commons.collections.keyvalue.AbstractKeyValue
`getKey, getValue, toString`

Methods inherited from class java.lang.Object
`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

Constructor Detail

### DefaultKeyValue

    public DefaultKeyValue()

  Constructs a new pair with a null key and null value.

### DefaultKeyValue

    public DefaultKeyValue(java.lang.Object key,
                           java.lang.Object value)

  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)

  Constructs a new pair from the specified `KeyValue`.

  Parameters:
    `pair` - the pair to copy, must not be null
  Throws:
    `java.lang.NullPointerException` - if the entry is null

### DefaultKeyValue

    public DefaultKeyValue(java.util.Map.Entry entry)

  Constructs a new pair from the specified `Map.Entry`.

  Parameters:
    `entry` - the entry to copy, must not be null
  Throws:
    `java.lang.NullPointerException` - if the entry is null

Method Detail

### setKey

    public java.lang.Object setKey(java.lang.Object key)

  Sets the key.

  Parameters:
    `key` - the new key
  Returns:
    the old key
  Throws:
    `java.lang.IllegalArgumentException` - if key is this object

### setValue

    public java.lang.Object setValue(java.lang.Object value)

  Sets the value.

  Parameters:
    `value` - the new value
  Returns:
    the old value of the value
  Throws:
    `java.lang.IllegalArgumentException` - if value is this object

### toMapEntry

    public java.util.Map.Entry toMapEntry()

  Returns a new `Map.Entry` object with key and value from this pair.

  Returns:
    a MapEntry instance

### equals

    public boolean equals(java.lang.Object obj)

  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 `java.lang.Object`
  Parameters:
    `obj` - the object to compare to
  Returns:
    true if equal key and value

### hashCode

    public int hashCode()

  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 `java.lang.Object`
  Returns:
    a suitable hash code

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2001-2008 The Apache Software Foundation. All Rights Reserved.