Package org.approvej.database.jdbc
Record Class QueryResult
java.lang.Object
java.lang.Record
org.approvej.database.jdbc.QueryResult
- Record Components:
columnNames- the column headersrows- each row as a list of string-rendered cell values
@NullMarked
public record QueryResult(List<String> columnNames, List<List<String>> rows)
extends Record
Represents the result of a database query as column names and row data.
Use of(ResultSet) to create an instance from a JDBC ResultSet, or construct
one directly for testing purposes.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of thecolumnNamesrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.static QueryResultMaterializes the givenResultSetinto aQueryResult.rows()Returns the value of therowsrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
QueryResult
Compact constructor to ensure immutability.
-
-
Method Details
-
of
Materializes the givenResultSetinto aQueryResult.The result set is consumed from its current position to the end. It is not closed by this method.
- Parameters:
resultSet- the result set to read- Returns:
- the materialized query result
- Throws:
SQLException- if a database access error occurs
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
columnNames
Returns the value of thecolumnNamesrecord component.- Returns:
- the value of the
columnNamesrecord component
-
rows
Returns the value of therowsrecord component.- Returns:
- the value of the
rowsrecord component
-