package io.ebeaninternal.server.persist.platform;
import io.ebean.core.type.ScalarType;
import io.ebeaninternal.server.type.DataBind;
import java.sql.SQLException;
import java.util.Collection;
public class MultiValueBind {
@FunctionalInterface
public interface BindOne {
void bind(Object value) throws SQLException;
}
Object[] toArray(Collection<?> values, ScalarType<?> type) {
Object[] array = new Object[values.size()];
int i = 0;
for (Object value : values) {
array[i++] = type.toJdbcType(value);
}
return array;
}
public boolean isSupported() {
return false;
}
public boolean isTypeSupported(int jdbcType) {
return false;
}
public void bindMultiValues(DataBind dataBind, Collection<?> values, ScalarType<?> type, BindOne bindOne) throws SQLException {
for (Object value : values) {
if (!type.isJdbcNative()) {
value = type.toJdbcType(value);
}
bindOne.bind(value);
}
}
public String getInExpression(boolean not, ScalarType<?> type, int size) {
StringBuilder sb = new StringBuilder();
if (not) {
sb.append(" not");
}
sb.append(" in (?");
for (int i = 1; i < size; i++) {
sb.append(",?");
}
sb.append(")");
return sb.toString();
}
}