001package org.itsallcode.jdbc.resultset.generic; 002 003import java.util.List; 004 005/** 006 * Represents a generic row from a result set. 007 * 008 * @param rowIndex row index (zero based) 009 * @param columns column metadata 010 * @param columnValues values for each column 011 */ 012public record Row(int rowIndex, List<ColumnMetaData> columns, List<ColumnValue> columnValues) { 013 014 /** 015 * Get the value at a given column index (zero based). 016 * 017 * @param columnIndex column index (zero based) 018 * @return column value 019 */ 020 public ColumnValue get(final int columnIndex) { 021 return columnValues.get(columnIndex); 022 } 023 024 /** 025 * Get the value at a given column index (zero based) converted to the given 026 * type. 027 * 028 * @param columnIndex column index (zero based) 029 * @param type expected type 030 * @param <T> expected type 031 * @return column value 032 */ 033 public <T> T get(final int columnIndex, final Class<T> type) { 034 return get(columnIndex).getValue(type); 035 } 036}