package io.vertx.sqlclient.impl;
import io.vertx.sqlclient.desc.ColumnDescriptor;
import java.sql.JDBCType;
import java.util.List;
import java.util.stream.Collectors;
public class RowDesc {
private final List<String> columnNames;
private final List<ColumnDescriptor> columnDescriptors;
public RowDesc(List<String> columnNames) {
this(columnNames, columnNames.stream().map(colName -> new ColumnDescriptor() {
@Override
public String name() {
return colName;
}
@Override
public JDBCType jdbcType() {
return JDBCType.OTHER;
}
@Override
public boolean isArray() {
return false;
}
}).collect(Collectors.toList()));
}
public RowDesc(List<String> columnNames, List<ColumnDescriptor> columnDescriptors) {
this.columnNames = columnNames;
this.columnDescriptors = columnDescriptors;
}
public int columnIndex(String columnName) {
if (columnName == null) {
throw new NullPointerException("Column name must not be null");
}
return columnNames.indexOf(columnName);
}
public List<String> columnNames() {
return columnNames;
}
public List<ColumnDescriptor> columnDescriptor() {
return columnDescriptors;
}
@Override
public String toString() {
return "RowDesc{" +
"columns=" + columnNames +
'}';
}
}