net.dongliu.commons.lang.collection.Pair Maven / Gradle / Ivy
package net.dongliu.commons.lang.collection;
/**
* pair with members key and value.
*
* {@code Pair pair = Pair.of("test", 1);}
*
*
* @author Dong Liu
*/
public class Pair {
private K key;
private V value;
public static Pair of(S key, T value) {
Pair pair = new Pair<>();
pair.setKey(key);
pair.setValue(value);
return pair;
}
public K getKey() {
return key;
}
public void setKey(K key) {
this.key = key;
}
public V getValue() {
return value;
}
public void setValue(V value) {
this.value = value;
}
@Override
public String toString() {
return String.valueOf(key) + " -> " + String.valueOf(value);
}
}