org.itsallcode.jdbc.resultset.generic.SimpleMetaData Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of simple-jdbc Show documentation
Show all versions of simple-jdbc Show documentation
Library to simplify using JDBC
package org.itsallcode.jdbc.resultset.generic;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.util.List;
/**
* A wrapper for {@link ResultSetMetaData} to simplify usage.
*
* @param columns all column metadata for the result set
*/
public record SimpleMetaData(List columns) {
/**
* Create a new {@link SimpleMetaData} for a given {@link ResultSet}.
*
* @param resultSet the result set
* @return simple metadata
*/
public static SimpleMetaData create(final ResultSet resultSet) {
return new SimpleMetaData(ColumnMetaData.create(resultSet));
}
/**
* Get column metadata for a given index (one based).
*
* @param index column index (one based)
* @return column metadata
*/
public ColumnMetaData getColumnByIndex(final int index) {
return columns.get(index - 1);
}
}