Interface Tuple
- All Known Subinterfaces:
SqlRow
Note: "\"MYCOLUMN\"" is equivalent to a normalized name "MYCOLUMN".
Provides a specialized method for some value-types to avoid boxing/unboxing.
-
Method Summary
Modifier and TypeMethodDescriptionboolean
booleanValue
(int columnIndex) Getsboolean
column value.boolean
booleanValue
(String columnName) Gets aboolean
column value.byte[]
bytesValue
(int columnIndex) Gets abyte[]
column value.byte[]
bytesValue
(String columnName) Gets abyte[]
column value.byte
byteValue
(int columnIndex) Getsbyte
column value.byte
Gets abyte
column value.int
Gets a number of columns in the tuple.int
columnIndex
(String columnName) Gets an index of the column with the specified name.columnName
(int columnIndex) Gets a name of the column with the specified index.static Tuple
Creates a tuple copy.static Tuple
create()
Creates a tuple.static Tuple
create
(int capacity) Creates a tuple with a specified initial capacity.static Tuple
Creates a tuple from a given mapping.datetimeValue
(int columnIndex) Gets aLocalDateTime
column value.datetimeValue
(String columnName) Gets aLocalDateTime
column value.dateValue
(int columnIndex) Gets aLocalDate
column value.Gets aLocalDate
column value.decimalValue
(int columnIndex) Gets aBigDecimal
column value.decimalValue
(String columnName) Gets aBigDecimal
column value.double
doubleValue
(int columnIndex) Gets adouble
column value.double
doubleValue
(String columnName) Gets adouble
column value.boolean
Indicates whether another object is "equal to" the specified one.static boolean
Compares tuples for equality.float
floatValue
(int columnIndex) Gets afloat
column value.float
floatValue
(String columnName) Gets afloat
column value.int
hashCode()
Returns a hash code value for the tuple.static int
Returns a hash code value for the tuple.int
intValue
(int columnIndex) Gets aint
column value.int
Gets aint
column value.iterator()
long
longValue
(int columnIndex) Gets along
column value.long
Gets along
column value.Sets a column value.short
shortValue
(int columnIndex) Gets ashort
column value.short
shortValue
(String columnName) Gets ashort
column value.stringValue
(int columnIndex) Gets aString
column value.stringValue
(String columnName) Gets aString
column value.timestampValue
(int columnIndex) Gets aInstant
column value.timestampValue
(String columnName) Gets aInstant
column value.timeValue
(int columnIndex) Gets aLocalTime
column value.Gets aLocalTime
column value.uuidValue
(int columnIndex) Gets aUUID
column value.Gets aUUID
column value.<T> T
value
(int columnIndex) Gets a column value for the given column index.<T> T
Gets a column value for the given column name.<T> T
valueOrDefault
(String columnName, T defaultValue) Gets a column value if the column with the specified name is present in the tuple; returns a default value otherwise.Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Method Details
-
create
Creates a tuple.- Returns:
- A new tuple.
-
create
Creates a tuple with a specified initial capacity.- Parameters:
capacity
- Initial capacity.- Returns:
- A new tuple.
-
create
Creates a tuple from a given mapping.- Parameters:
map
- Column values.- Returns:
- A new tuple.
-
copy
Creates a tuple copy.- Parameters:
tuple
- Tuple to copy.- Returns:
- A new tuple.
-
hashCode
Returns a hash code value for the tuple.The hash code of a tuple is the sum of the hash codes of each pair of column name and column value. Therefore,
m1.equals(m2)
implies thatm1.hashCode()==m2.hashCode()
for any tuplesm1
andm2
, as required by the general contract ofObject.hashCode()
.The hash code of a pair of column name and column value
i
is:(columnName(i).hashCode()) ^ (value(i)==null ? 0 : value(i).hashCode())
- Parameters:
tuple
- Tuple.- Returns:
- The hash code value for the tuple.
-
hashCode
int hashCode()Returns a hash code value for the tuple. -
equals
Compares tuples for equality.Returns
true
if both tuples represent the same column name-to-value mapping.This implementation first checks if both tuples is of same size. If not, it returns
false
. If yes, it iterates over columns of the first tuple and checks that the second tuple contains each mapping that the first one contains. If the second tuple fails to contain such a mapping,false
is returned. If the iteration completes,true
is returned.- Parameters:
firstTuple
- First tuple to compare.secondTuple
- Second tuple to compare.- Returns:
true
if the first tuple is equal to the second tuple.
-
equals
Indicates whether another object is "equal to" the specified one. -
columnCount
int columnCount()Gets a number of columns in the tuple.- Returns:
- Number of columns.
-
columnName
Gets a name of the column with the specified index.- Parameters:
columnIndex
- Column index.- Returns:
- Normalized column name in SQL-parser style notation; e.g.,
"\"MyColumn\"" - quoted value for a name of the column with respect to case sensitivity, "MYCOLUMN" - column name in uppercase, otherwise. - Throws:
IndexOutOfBoundsException
- If a value for a column with the given index doesn't exists.
-
columnIndex
Gets an index of the column with the specified name.- Parameters:
columnName
- Column name in SQL-parser style notation; e.g.,
"myColumn" - "MYCOLUMN", returns the index of the column ignores case sensitivity,
"\"MyColumn\"" - "MyColumn", returns the index of the column with respect to case sensitivity.- Returns:
- Column index, or
-1
if the column with the given name is not present.
-
valueOrDefault
Gets a column value if the column with the specified name is present in the tuple; returns a default value otherwise.- Type Parameters:
T
- Default value type.- Parameters:
columnName
- Column name in SQL-parser style notation; e.g.,
"myColumn" - "MYCOLUMN", returns the index of the column ignores case sensitivity,
"\"MyColumn\"" - "MyColumn", returns the index of the column with respect to case sensitivity.defaultValue
- Default value.- Returns:
- Column value if the tuple contains a column with the specified name. Otherwise,
defaultValue
.
-
set
Sets a column value.- Parameters:
columnName
- Column name in SQL-parser style notation; e.g.,
"myColumn" - "MYCOLUMN", returns the index of the column ignores case sensitivity,
"\"MyColumn\"" - "MyColumn", returns the index of the column with respect to case sensitivity.value
- Value to set.- Returns:
this
for chaining.
-
value
Gets a column value for the given column name.- Type Parameters:
T
- Value type.- Parameters:
columnName
- Column name in SQL-parser style notation; e.g.,
"myColumn" - "MYCOLUMN", returns the index of the column ignores case sensitivity,
"\"MyColumn\"" - "MyColumn", returns the index of the column with respect to case sensitivity.- Returns:
- Column value.
- Throws:
IllegalArgumentException
- If no column with the given name exists.
-
value
@Nullable <T> T value(int columnIndex) Gets a column value for the given column index.- Type Parameters:
T
- Value type.- Parameters:
columnIndex
- Column index.- Returns:
- Column value.
- Throws:
IndexOutOfBoundsException
- If no column with the given index exists.
-
booleanValue
Gets aboolean
column value.- Parameters:
columnName
- Column name in SQL-parser style notation; e.g.,
"myColumn" - "MYCOLUMN", returns the index of the column ignores case sensitivity,
"\"MyColumn\"" - "MyColumn", returns the index of the column with respect to case sensitivity.- Returns:
- Column value.
- Throws:
IllegalArgumentException
- If no column with given name exists.
-
booleanValue
boolean booleanValue(int columnIndex) Getsboolean
column value.- Parameters:
columnIndex
- Column index.- Returns:
- Column value.
- Throws:
IndexOutOfBoundsException
- If no column with the given index exists.
-
byteValue
Gets abyte
column value.- Parameters:
columnName
- Column name in SQL-parser style notation; e.g.,
"myColumn" - "MYCOLUMN", returns the index of the column ignores case sensitivity,
"\"MyColumn\"" - "MyColumn", returns the index of the column with respect to case sensitivity.- Returns:
- Column value.
- Throws:
IllegalArgumentException
- If no column with given name exists.
-
byteValue
byte byteValue(int columnIndex) Getsbyte
column value.- Parameters:
columnIndex
- Column index.- Returns:
- Column value.
- Throws:
IndexOutOfBoundsException
- If no column with the given index exists.
-
shortValue
Gets ashort
column value.- Parameters:
columnName
- Column name in SQL-parser style notation; e.g.,
"myColumn" - "MYCOLUMN", returns the index of the column ignores case sensitivity,
"\"MyColumn\"" - "MyColumn", returns the index of the column with respect to case sensitivity.- Returns:
- Column value.
- Throws:
IllegalArgumentException
- If no column with the given name exists.
-
shortValue
short shortValue(int columnIndex) Gets ashort
column value.- Parameters:
columnIndex
- Column index.- Returns:
- Column value.
- Throws:
IndexOutOfBoundsException
- If no column with the given index exists.
-
intValue
Gets aint
column value.- Parameters:
columnName
- Column name in SQL-parser style notation; e.g.,
"myColumn" - "MYCOLUMN", returns the index of the column ignores case sensitivity,
"\"MyColumn\"" - "MyColumn", returns the index of the column with respect to case sensitivity.- Returns:
- Column value.
- Throws:
IllegalArgumentException
- If no column with the given name exists.
-
intValue
int intValue(int columnIndex) Gets aint
column value.- Parameters:
columnIndex
- Column index.- Returns:
- Column value.
- Throws:
IndexOutOfBoundsException
- If no column with the given index exists.
-
longValue
Gets along
column value.- Parameters:
columnName
- Column name in SQL-parser style notation; e.g.,
"myColumn" - "MYCOLUMN", returns the index of the column ignores case sensitivity,
"\"MyColumn\"" - "MyColumn", returns the index of the column with respect to case sensitivity.- Returns:
- Column value.
- Throws:
IllegalArgumentException
- If no column with the given name exists.
-
longValue
long longValue(int columnIndex) Gets along
column value.- Parameters:
columnIndex
- Column index.- Returns:
- Column value.
- Throws:
IndexOutOfBoundsException
- If no column with the given index exists.
-
floatValue
Gets afloat
column value.- Parameters:
columnName
- Column name in SQL-parser style notation; e.g.,
"myColumn" - "MYCOLUMN", returns the index of the column ignores case sensitivity,
"\"MyColumn\"" - "MyColumn", returns the index of the column with respect to case sensitivity.- Returns:
- Column value.
- Throws:
IllegalArgumentException
- If no column with the given name exists.
-
floatValue
float floatValue(int columnIndex) Gets afloat
column value.- Parameters:
columnIndex
- Column index.- Returns:
- Column value.
- Throws:
IndexOutOfBoundsException
- If no column with the given index exists.
-
doubleValue
Gets adouble
column value.- Parameters:
columnName
- Column name in SQL-parser style notation; e.g.,
"myColumn" - "MYCOLUMN", returns the index of the column ignores case sensitivity,
"\"MyColumn\"" - "MyColumn", returns the index of the column with respect to case sensitivity.- Returns:
- Column value.
- Throws:
IllegalArgumentException
- If no column with the given name exists.
-
doubleValue
double doubleValue(int columnIndex) Gets adouble
column value.- Parameters:
columnIndex
- Column index.- Returns:
- Column value.
- Throws:
IndexOutOfBoundsException
- If no column with the given index exists.
-
decimalValue
Gets aBigDecimal
column value.- Parameters:
columnName
- Column name in SQL-parser style notation; e.g.,
"myColumn" - "MYCOLUMN", returns the index of the column ignores case sensitivity,
"\"MyColumn\"" - "MyColumn", returns the index of the column with respect to case sensitivity.- Returns:
- Column value.
- Throws:
IllegalArgumentException
- If no column with the given name exists.
-
decimalValue
Gets aBigDecimal
column value.- Parameters:
columnIndex
- Column index.- Returns:
- Column value.
- Throws:
IndexOutOfBoundsException
- If no column with the given index exists.
-
stringValue
Gets aString
column value.- Parameters:
columnName
- Column name in SQL-parser style notation; e.g.,
"myColumn" - "MYCOLUMN", returns the index of the column ignores case sensitivity,
"\"MyColumn\"" - "MyColumn", returns the index of the column with respect to case sensitivity.- Returns:
- Column value.
- Throws:
IllegalArgumentException
- If no column with the given name exists.
-
stringValue
Gets aString
column value.- Parameters:
columnIndex
- Column index.- Returns:
- Column value.
- Throws:
IndexOutOfBoundsException
- If no column with the given index exists.
-
bytesValue
Gets abyte[]
column value.- Parameters:
columnName
- Column name in SQL-parser style notation; e.g.,
"myColumn" - "MYCOLUMN", returns the index of the column ignores case sensitivity,
"\"MyColumn\"" - "MyColumn", returns the index of the column with respect to case sensitivity.- Returns:
- Column value.
- Throws:
IllegalArgumentException
- If no column with the given name exists.
-
bytesValue
byte[] bytesValue(int columnIndex) Gets abyte[]
column value.- Parameters:
columnIndex
- Column index.- Returns:
- Column value.
- Throws:
IndexOutOfBoundsException
- If no column with the given index exists.
-
uuidValue
Gets aUUID
column value.- Parameters:
columnName
- Column name in SQL-parser style notation; e.g.,
"myColumn" - "MYCOLUMN", returns the index of the column ignores case sensitivity,
"\"MyColumn\"" - "MyColumn", returns the index of the column with respect to case sensitivity.- Returns:
- Column value.
- Throws:
IllegalArgumentException
- If no column with the given name exists.
-
uuidValue
Gets aUUID
column value.- Parameters:
columnIndex
- Column index.- Returns:
- Column value.
- Throws:
IndexOutOfBoundsException
- If no column with the given index exists.
-
dateValue
Gets aLocalDate
column value.- Parameters:
columnName
- Column name in SQL-parser style notation; e.g.,
"myColumn" - "MYCOLUMN", returns the index of the column ignores case sensitivity,
"\"MyColumn\"" - "MyColumn", returns the index of the column with respect to case sensitivity.- Returns:
- Column value.
- Throws:
IllegalArgumentException
- If no column with the given name exists.
-
dateValue
Gets aLocalDate
column value.- Parameters:
columnIndex
- Column index.- Returns:
- Column value.
- Throws:
IndexOutOfBoundsException
- If no column with the given index exists.
-
timeValue
Gets aLocalTime
column value.- Parameters:
columnName
- Column name in SQL-parser style notation; e.g.,
"myColumn" - "MYCOLUMN", returns the index of the column ignores case sensitivity,
"\"MyColumn\"" - "MyColumn", returns the index of the column with respect to case sensitivity.- Returns:
- Column value.
- Throws:
IllegalArgumentException
- If no column with the given name exists.
-
timeValue
Gets aLocalTime
column value.- Parameters:
columnIndex
- Column index.- Returns:
- Column value.
- Throws:
IndexOutOfBoundsException
- If no column with the given index exists.
-
datetimeValue
Gets aLocalDateTime
column value.- Parameters:
columnName
- Column name in SQL-parser style notation; e.g.,
"myColumn" - "MYCOLUMN", returns the index of the column ignores case sensitivity,
"\"MyColumn\"" - "MyColumn", returns the index of the column with respect to case sensitivity.- Returns:
- Column value.
- Throws:
IllegalArgumentException
- If no column with the given name exists.
-
datetimeValue
Gets aLocalDateTime
column value.- Parameters:
columnIndex
- Column index.- Returns:
- Column value.
- Throws:
IndexOutOfBoundsException
- If no column with the iven index exists.
-
timestampValue
Gets aInstant
column value.- Parameters:
columnName
- Column name in SQL-parser style notation; e.g.,
"myColumn" - "MYCOLUMN", returns the index of the column ignores case sensitivity,
"\"MyColumn\"" - "MyColumn", returns the index of the column with respect to case sensitivity.- Returns:
- Column value.
- Throws:
IllegalArgumentException
- If no column with the given name exists.
-
timestampValue
Gets aInstant
column value.- Parameters:
columnIndex
- Column index.- Returns:
- Column value.
- Throws:
IndexOutOfBoundsException
- If no column with the given index exists.
-
iterator
-