com.datastax.collection.KeyValue Maven / Gradle / Ivy
package com.datastax.collection;
import java.io.Serializable;
public class KeyValue implements Serializable {
private final K key;
private final V value;
public KeyValue(K key, V value) {
this.key = key;
this.value = value;
}
public K key() {
return key;
}
public K getKey() {
return key;
}
public V value() {
return value;
}
public V getValue() {
return value;
}
@Override
public String toString() {
return "(" + key() + "," + value() + ")";
}
@Override
@SuppressWarnings("rawtypes")
public boolean equals(Object that) {
if (!(that instanceof KeyValue))
return false;
KeyValue,?> thatPair = (KeyValue,?>) that;
return key.equals(thatPair.key)
&& value.equals(thatPair.value);
}
@Override
public int hashCode() {
return 31 * key.hashCode() + value.hashCode();
}
}