public class Pair<K, V> {
public static <K, V> Pair<K, V> of(K key, V value) {
return new Pair<>("%s = %s", key, value);
}
public static <K> Pair<K, String> of(K key, String value) {
return new Pair<>("%s = '%s'", key, value);
}
private final String format;
private final K key;
private final V value;
private Pair(String format, K key, V value) {
this.format = format;
this.key = key;
this.value = value;
}
public K getKey() {
return key;
}
public V getValue() {
return value;
}
@Override
public String toString() {
return String.format(format, key, value);
}
}