Class CommonResultSetConverters

java.lang.Object
com.github.tadukoo.database.mysql.CommonResultSetConverters

public class CommonResultSetConverters extends Object
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 Details

    • CommonResultSetConverters

      private CommonResultSetConverters()
      Not allowed to instantiate
  • Method Details

    • check

      public static Boolean check(ResultSet resultSet) throws SQLException
      Checks if any rows were returned in the ResultSet
      Parameters:
      resultSet - The ResultSet to be checked
      Returns:
      true if any rows are in the ResultSet, otherwise false
      Throws:
      SQLException - If anything goes wrong
    • simpleItem

      public static <Type> Type simpleItem(ResultSet resultSet, com.github.tadukoo.util.functional.function.ThrowingFunction<Integer,Type,SQLException> getter) throws SQLException
      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 - The ResultSet to extract the value from
      getter - The ThrowingFunction to 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 the ResultSet
    • simpleList

      public static <Type> List<Type> simpleList(ResultSet resultSet, com.github.tadukoo.util.functional.function.ThrowingFunction<Integer,Type,SQLException> getter) throws SQLException
      This will convert multiple rows of a ResultSet into 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 - The ResultSet to extract the values from
      getter - The ThrowingFunction to use to convert rows into values
      Returns:
      The List of values found from the rows
      Throws:
      SQLException - If anything goes wrong
    • singleBoolean

      public static Boolean singleBoolean(ResultSet resultSet) throws SQLException
      To be used when only one row is expected, this will convert that single row into a single boolean
      Parameters:
      resultSet - The ResultSet to 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 the ResultSet
    • booleans

      public static List<Boolean> booleans(ResultSet resultSet) throws SQLException
      This will convert multiple rows of a ResultSet into a List of booleans, a single boolean for each row
      Parameters:
      resultSet - The ResultSet to extract the booleans from
      Returns:
      The List of booleans found from the rows
      Throws:
      SQLException - If anything goes wrong
    • singleInteger

      public static Integer singleInteger(ResultSet resultSet) throws SQLException
      To be used when only one row is expected, this will convert that single row into a single integer
      Parameters:
      resultSet - The ResultSet to 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 the ResultSet
    • integers

      public static List<Integer> integers(ResultSet resultSet) throws SQLException
      This will convert multiple rows of a ResultSet into a List of integers, a single integer for each row
      Parameters:
      resultSet - The ResultSet to extract the integers from
      Returns:
      The List of integers found from the rows
      Throws:
      SQLException - If anything goes wrong
    • singleString

      public static String singleString(ResultSet resultSet) throws SQLException
      To be used when only one row is expected, this will convert that single row into a single String
      Parameters:
      resultSet - The ResultSet to 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 the ResultSet
    • strings

      public static List<String> strings(ResultSet resultSet) throws SQLException
      This will convert multiple rows of a ResultSet into a List of Strings, a single String for each row
      Parameters:
      resultSet - The ResultSet to extract the Strings from
      Returns:
      The List of Strings found from the rows
      Throws:
      SQLException - If anything goes wrong
    • singleTime

      public static Time singleTime(ResultSet resultSet) throws SQLException
      To be used when only one row is expected, this will convert that single row into a single Time
      Parameters:
      resultSet - The ResultSet to extract the Time from
      Returns:
      The Time found from the single row
      Throws:
      SQLException - If anything goes wrong, or if more than one row is present in the ResultSet
    • times

      public static List<Time> times(ResultSet resultSet) throws SQLException
      This will convert multiple rows of a ResultSet into a List of Times, a single Time for each row
      Parameters:
      resultSet - The ResultSet to extract the Times from
      Returns:
      The List of Times found from the rows
      Throws:
      SQLException - If anything goes wrong
    • singleTimestamp

      public static Timestamp singleTimestamp(ResultSet resultSet) throws SQLException
      To be used when only one row is expected, this will convert that single row into a single Timestamp
      Parameters:
      resultSet - The ResultSet to extract the Timestamp from
      Returns:
      The Timestamp found from the single row
      Throws:
      SQLException - If anything goes wrong, or if more than one row is present in the ResultSet
    • timestamps

      public static List<Timestamp> timestamps(ResultSet resultSet) throws SQLException
      This will convert multiple rows of a ResultSet into a List of Timestamps, a single Timestamp for each row
      Parameters:
      resultSet - The ResultSet to extract the Timestamps from
      Returns:
      The List of Timestamps found from the rows
      Throws:
      SQLException - If anything goes wrong
    • singleDate

      public static Date singleDate(ResultSet resultSet) throws SQLException
      To be used when only one row is expected, this will convert that single row into a single Date
      Parameters:
      resultSet - The ResultSet to extract the Date from
      Returns:
      The Date found from the single row
      Throws:
      SQLException - If anything goes wrong, or if more than one row is present in the ResultSet
    • dates

      public static List<Date> dates(ResultSet resultSet) throws SQLException
      This will convert multiple rows of a ResultSet into a List of Dates, a single Date for each row
      Parameters:
      resultSet - The ResultSet to extract the Dates from
      Returns:
      The List of Dates found from the rows
      Throws:
      SQLException - If anything goes wrong
    • singleShort

      public static Short singleShort(ResultSet resultSet) throws SQLException
      To be used when only one row is expected, this will convert that single row into a single Short
      Parameters:
      resultSet - The ResultSet to 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 the ResultSet
    • shorts

      public static List<Short> shorts(ResultSet resultSet) throws SQLException
      This will convert multiple rows of a ResultSet into a List of shorts, a single short for each row
      Parameters:
      resultSet - The ResultSet to extract the short from
      Returns:
      The List of shorts found from the rows
      Throws:
      SQLException - If anything goes wrong
    • singleLong

      public static Long singleLong(ResultSet resultSet) throws SQLException
      To be used when only one row is expected, this will convert that single row into a single long
      Parameters:
      resultSet - The ResultSet to 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 the ResultSet
    • longs

      public static List<Long> longs(ResultSet resultSet) throws SQLException
      This will convert multiple rows of a ResultSet into a List of longs, a single long for each row
      Parameters:
      resultSet - The ResultSet to extract the long from
      Returns:
      The List of longs found from the rows
      Throws:
      SQLException - If anything goes wrong
    • singleFloat

      public static Float singleFloat(ResultSet resultSet) throws SQLException
      To be used when only one row is expected, this will convert that single row into a single float
      Parameters:
      resultSet - The ResultSet to 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 the ResultSet
    • floats

      public static List<Float> floats(ResultSet resultSet) throws SQLException
      This will convert multiple rows of a ResultSet into a List of floats, a single float for each row
      Parameters:
      resultSet - The ResultSet to extract the float from
      Returns:
      The List of floats found from the rows
      Throws:
      SQLException - If anything goes wrong
    • singleDouble

      public static Double singleDouble(ResultSet resultSet) throws SQLException
      To be used when only one row is expected, this will convert that single row into a single double
      Parameters:
      resultSet - The ResultSet to 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 the ResultSet
    • doubles

      public static List<Double> doubles(ResultSet resultSet) throws SQLException
      This will convert multiple rows of a ResultSet into a List of doubles, a single double for each row
      Parameters:
      resultSet - The ResultSet to extract the double from
      Returns:
      The List of doubles found from the rows
      Throws:
      SQLException - If anything goes wrong