com.clickhouse.r2dbc.ClickHousePair Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of clickhouse-r2dbc Show documentation
Show all versions of clickhouse-r2dbc Show documentation
R2DBC driver for ClickHouse
package com.clickhouse.r2dbc;
import java.io.Serializable;
import java.util.Map.Entry;
/**
* Immutable pair with two values: left and right.
*/
public class ClickHousePair implements Entry, Serializable {
public static final ClickHousePair, ?> EMPTY = new ClickHousePair<>(null, null);
@SuppressWarnings("unchecked")
public static final ClickHousePair of(L left, R right) {
if (left == null && right == null) {
return (ClickHousePair) EMPTY;
}
return new ClickHousePair<>(left, right);
}
private final L left;
private final R right;
public L getLeft() {
return left;
}
public R getRight() {
return right;
}
protected ClickHousePair(L left, R right) {
this.left = left;
this.right = right;
}
@Override
public L getKey() {
return left;
}
@Override
public R getValue() {
return right;
}
@Override
public R setValue(R value) {
throw new IllegalStateException("Cannot modify value");
}
}