Package io.permazen.kv
Class KVPair
java.lang.Object
io.permazen.kv.KVPair
- All Implemented Interfaces:
Cloneable
A key/value pair.
Note: the internal byte arrays are not copied; therefore, values passed to the constructor
or returned from the accessor methods must not be modified if instances are to remain immutable.
To ensure safety, use clone()
.
-
Constructor Summary
-
Method Summary
-
Constructor Details
-
KVPair
public KVPair(byte[] key, byte[] value) Constructor. The given arrays are copied.- Parameters:
key
- keyvalue
- value- Throws:
IllegalArgumentException
- ifkey
orvalue
is null
-
KVPair
Constructor. The given key and value arrays are copied.- Parameters:
entry
- map entry- Throws:
IllegalArgumentException
- ifentry
or its key or value is null
-
-
Method Details
-
getKey
public byte[] getKey()Get the key.- Returns:
- the key
-
getValue
public byte[] getValue()Get the value.- Returns:
- the value
-
clone
Deep-clone this instance. Copys this instance as well as the key and valuebyte[]
arrays. -
toString
-
equals
Compare for equality.Two
KVPair
instances are equal if the keys and values both match according toArrays.equals(byte[], byte[])
. -
hashCode
public int hashCode()Calculate hash code.The hash code of a
KVPair
is the exclusive-OR of the hash codes of the key and the value, each according toArrays.hashCode(byte[])
.
-