Class CommonResultSetConverters
java.lang.Object
com.github.tadukoo.database.mysql.CommonResultSetConverters
Common Result Set Converters are used for common/simple conversions from a
ResultSet to values- Since:
- Alpha v.0.1
- Version:
- Alpha v.0.3
- Author:
- Logan Ferree (Tadukoo)
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionThis will convert multiple rows of aResultSetinto a List of booleans, a single boolean for each rowstatic BooleanChecks if any rows were returned in theResultSetThis will convert multiple rows of aResultSetinto a List of doubles, a single double for each rowThis will convert multiple rows of aResultSetinto a List of floats, a single float for each rowThis will convert multiple rows of aResultSetinto a List of integers, a single integer for each rowThis will convert multiple rows of aResultSetinto a List of longs, a single long for each rowThis will convert multiple rows of aResultSetinto a List of shorts, a single short for each rowstatic <Type> TypesimpleItem(ResultSet resultSet, com.github.tadukoo.util.functional.function.ThrowingFunction<Integer, Type, SQLException> getter) To be used when only one row is expected, this will convert that single row into a single value using the given getterstatic <Type> List<Type>simpleList(ResultSet resultSet, com.github.tadukoo.util.functional.function.ThrowingFunction<Integer, Type, SQLException> getter) This will convert multiple rows of aResultSetinto a List of values, a single value for each row using the given getterstatic BooleansingleBoolean(ResultSet resultSet) To be used when only one row is expected, this will convert that single row into a single booleanstatic DatesingleDate(ResultSet resultSet) To be used when only one row is expected, this will convert that single row into a singleDatestatic DoublesingleDouble(ResultSet resultSet) To be used when only one row is expected, this will convert that single row into a single doublestatic FloatsingleFloat(ResultSet resultSet) To be used when only one row is expected, this will convert that single row into a single floatstatic IntegersingleInteger(ResultSet resultSet) To be used when only one row is expected, this will convert that single row into a single integerstatic LongsingleLong(ResultSet resultSet) To be used when only one row is expected, this will convert that single row into a single longstatic ShortsingleShort(ResultSet resultSet) To be used when only one row is expected, this will convert that single row into a single Shortstatic StringsingleString(ResultSet resultSet) To be used when only one row is expected, this will convert that single row into a single Stringstatic TimesingleTime(ResultSet resultSet) To be used when only one row is expected, this will convert that single row into a singleTimestatic TimestampsingleTimestamp(ResultSet resultSet) To be used when only one row is expected, this will convert that single row into a singleTimestampThis will convert multiple rows of aResultSetinto a List of Strings, a single String for each rowtimestamps(ResultSet resultSet) This will convert multiple rows of aResultSetinto a List ofTimestamps, a singleTimestampfor each row
-
Constructor Details
-
CommonResultSetConverters
private CommonResultSetConverters()Not allowed to instantiate
-
-
Method Details
-
check
Checks if any rows were returned in theResultSet- Parameters:
resultSet- TheResultSetto be checked- Returns:
trueif any rows are in theResultSet, otherwisefalse- Throws:
SQLException- If anything goes wrong
-
simpleItem
public static <Type> Type simpleItem(ResultSet resultSet, com.github.tadukoo.util.functional.function.ThrowingFunction<Integer, Type, throws SQLExceptionSQLException> getter) To be used when only one row is expected, this will convert that single row into a single value using the given getter- Type Parameters:
Type- The Type of value to be returned- Parameters:
resultSet- TheResultSetto extract the value fromgetter- TheThrowingFunctionto use to convert the row into a value- Returns:
- The value found from the single row
- Throws:
SQLException- If anything goes wrong, or if more than one row is present in theResultSet
-
simpleList
public static <Type> List<Type> simpleList(ResultSet resultSet, com.github.tadukoo.util.functional.function.ThrowingFunction<Integer, Type, throws SQLExceptionSQLException> getter) This will convert multiple rows of aResultSetinto a List of values, a single value for each row using the given getter- Type Parameters:
Type- The Type of values to be returned- Parameters:
resultSet- TheResultSetto extract the values fromgetter- TheThrowingFunctionto use to convert rows into values- Returns:
- The List of values found from the rows
- Throws:
SQLException- If anything goes wrong
-
singleBoolean
To be used when only one row is expected, this will convert that single row into a single boolean- Parameters:
resultSet- TheResultSetto extract the boolean from- Returns:
- The boolean found from the single row
- Throws:
SQLException- If anything goes wrong, or if more than one row is present in theResultSet
-
booleans
This will convert multiple rows of aResultSetinto a List of booleans, a single boolean for each row- Parameters:
resultSet- TheResultSetto extract the booleans from- Returns:
- The List of booleans found from the rows
- Throws:
SQLException- If anything goes wrong
-
singleInteger
To be used when only one row is expected, this will convert that single row into a single integer- Parameters:
resultSet- TheResultSetto extract the integer from- Returns:
- The integer found from the single row
- Throws:
SQLException- If anything goes wrong, or if more than one row is present in theResultSet
-
integers
This will convert multiple rows of aResultSetinto a List of integers, a single integer for each row- Parameters:
resultSet- TheResultSetto extract the integers from- Returns:
- The List of integers found from the rows
- Throws:
SQLException- If anything goes wrong
-
singleString
To be used when only one row is expected, this will convert that single row into a single String- Parameters:
resultSet- TheResultSetto extract the String from- Returns:
- The String found from the single row
- Throws:
SQLException- If anything goes wrong, or if more than one row is present in theResultSet
-
strings
This will convert multiple rows of aResultSetinto a List of Strings, a single String for each row- Parameters:
resultSet- TheResultSetto extract the Strings from- Returns:
- The List of Strings found from the rows
- Throws:
SQLException- If anything goes wrong
-
singleTime
To be used when only one row is expected, this will convert that single row into a singleTime- Parameters:
resultSet- TheResultSetto extract theTimefrom- Returns:
- The
Timefound from the single row - Throws:
SQLException- If anything goes wrong, or if more than one row is present in theResultSet
-
times
- Parameters:
resultSet- TheResultSetto extract theTimesfrom- Returns:
- The List of
Timesfound from the rows - Throws:
SQLException- If anything goes wrong
-
singleTimestamp
To be used when only one row is expected, this will convert that single row into a singleTimestamp- Parameters:
resultSet- TheResultSetto extract theTimestampfrom- Returns:
- The
Timestampfound from the single row - Throws:
SQLException- If anything goes wrong, or if more than one row is present in theResultSet
-
timestamps
This will convert multiple rows of aResultSetinto a List ofTimestamps, a singleTimestampfor each row- Parameters:
resultSet- TheResultSetto extract theTimestampsfrom- Returns:
- The List of
Timestampsfound from the rows - Throws:
SQLException- If anything goes wrong
-
singleDate
To be used when only one row is expected, this will convert that single row into a singleDate- Parameters:
resultSet- TheResultSetto extract theDatefrom- Returns:
- The
Datefound from the single row - Throws:
SQLException- If anything goes wrong, or if more than one row is present in theResultSet
-
dates
- Parameters:
resultSet- TheResultSetto extract theDatesfrom- Returns:
- The List of
Datesfound from the rows - Throws:
SQLException- If anything goes wrong
-
singleShort
To be used when only one row is expected, this will convert that single row into a single Short- Parameters:
resultSet- TheResultSetto extract the Short from- Returns:
- The Short found from the single row
- Throws:
SQLException- If anything goes wrong, or if more than one row is present in theResultSet
-
shorts
This will convert multiple rows of aResultSetinto a List of shorts, a single short for each row- Parameters:
resultSet- TheResultSetto extract the short from- Returns:
- The List of shorts found from the rows
- Throws:
SQLException- If anything goes wrong
-
singleLong
To be used when only one row is expected, this will convert that single row into a single long- Parameters:
resultSet- TheResultSetto extract the long from- Returns:
- The long found from the single row
- Throws:
SQLException- If anything goes wrong, or if more than one row is present in theResultSet
-
longs
This will convert multiple rows of aResultSetinto a List of longs, a single long for each row- Parameters:
resultSet- TheResultSetto extract the long from- Returns:
- The List of longs found from the rows
- Throws:
SQLException- If anything goes wrong
-
singleFloat
To be used when only one row is expected, this will convert that single row into a single float- Parameters:
resultSet- TheResultSetto extract the float from- Returns:
- The float found from the single row
- Throws:
SQLException- If anything goes wrong, or if more than one row is present in theResultSet
-
floats
This will convert multiple rows of aResultSetinto a List of floats, a single float for each row- Parameters:
resultSet- TheResultSetto extract the float from- Returns:
- The List of floats found from the rows
- Throws:
SQLException- If anything goes wrong
-
singleDouble
To be used when only one row is expected, this will convert that single row into a single double- Parameters:
resultSet- TheResultSetto extract the double from- Returns:
- The double found from the single row
- Throws:
SQLException- If anything goes wrong, or if more than one row is present in theResultSet
-
doubles
This will convert multiple rows of aResultSetinto a List of doubles, a single double for each row- Parameters:
resultSet- TheResultSetto extract the double from- Returns:
- The List of doubles found from the rows
- Throws:
SQLException- If anything goes wrong
-