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 TypeMethodDescriptionbooleanbooleanValue(int columnIndex) Getsbooleancolumn value.booleanbooleanValue(String columnName) Gets abooleancolumn value.byte[]bytesValue(int columnIndex) Gets abyte[]column value.byte[]bytesValue(String columnName) Gets abyte[]column value.bytebyteValue(int columnIndex) Getsbytecolumn value.byteGets abytecolumn value.intGets a number of columns in the tuple.intcolumnIndex(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 TupleCreates a tuple copy.static Tuplecreate()Creates a tuple.static Tuplecreate(int capacity) Creates a tuple with a specified initial capacity.static TupleCreates a tuple from a given mapping.datetimeValue(int columnIndex) Gets aLocalDateTimecolumn value.datetimeValue(String columnName) Gets aLocalDateTimecolumn value.dateValue(int columnIndex) Gets aLocalDatecolumn value.Gets aLocalDatecolumn value.decimalValue(int columnIndex) Gets aBigDecimalcolumn value.decimalValue(String columnName) Gets aBigDecimalcolumn value.doubledoubleValue(int columnIndex) Gets adoublecolumn value.doubledoubleValue(String columnName) Gets adoublecolumn value.booleanIndicates whether another object is "equal to" the specified one.static booleanCompares tuples for equality.floatfloatValue(int columnIndex) Gets afloatcolumn value.floatfloatValue(String columnName) Gets afloatcolumn value.inthashCode()Returns a hash code value for the tuple.static intReturns a hash code value for the tuple.intintValue(int columnIndex) Gets aintcolumn value.intGets aintcolumn value.iterator()longlongValue(int columnIndex) Gets alongcolumn value.longGets alongcolumn value.Sets a column value.shortshortValue(int columnIndex) Gets ashortcolumn value.shortshortValue(String columnName) Gets ashortcolumn value.stringValue(int columnIndex) Gets aStringcolumn value.stringValue(String columnName) Gets aStringcolumn value.timestampValue(int columnIndex) Gets aInstantcolumn value.timestampValue(String columnName) Gets aInstantcolumn value.timeValue(int columnIndex) Gets aLocalTimecolumn value.Gets aLocalTimecolumn value.uuidValue(int columnIndex) Gets aUUIDcolumn value.Gets aUUIDcolumn value.<T> Tvalue(int columnIndex) Gets a column value for the given column index.<T> TGets a column value for the given column name.<T> TvalueOrDefault(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 tuplesm1andm2, as required by the general contract ofObject.hashCode().The hash code of a pair of column name and column value
iis:(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
trueif 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,falseis returned. If the iteration completes,trueis returned.- Parameters:
firstTuple- First tuple to compare.secondTuple- Second tuple to compare.- Returns:
trueif 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
-1if 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:
thisfor 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 abooleancolumn 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) Getsbooleancolumn value.- Parameters:
columnIndex- Column index.- Returns:
- Column value.
- Throws:
IndexOutOfBoundsException- If no column with the given index exists.
-
byteValue
Gets abytecolumn 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) Getsbytecolumn value.- Parameters:
columnIndex- Column index.- Returns:
- Column value.
- Throws:
IndexOutOfBoundsException- If no column with the given index exists.
-
shortValue
Gets ashortcolumn 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 ashortcolumn value.- Parameters:
columnIndex- Column index.- Returns:
- Column value.
- Throws:
IndexOutOfBoundsException- If no column with the given index exists.
-
intValue
Gets aintcolumn 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 aintcolumn value.- Parameters:
columnIndex- Column index.- Returns:
- Column value.
- Throws:
IndexOutOfBoundsException- If no column with the given index exists.
-
longValue
Gets alongcolumn 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 alongcolumn value.- Parameters:
columnIndex- Column index.- Returns:
- Column value.
- Throws:
IndexOutOfBoundsException- If no column with the given index exists.
-
floatValue
Gets afloatcolumn 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 afloatcolumn value.- Parameters:
columnIndex- Column index.- Returns:
- Column value.
- Throws:
IndexOutOfBoundsException- If no column with the given index exists.
-
doubleValue
Gets adoublecolumn 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 adoublecolumn value.- Parameters:
columnIndex- Column index.- Returns:
- Column value.
- Throws:
IndexOutOfBoundsException- If no column with the given index exists.
-
decimalValue
Gets aBigDecimalcolumn 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 aBigDecimalcolumn value.- Parameters:
columnIndex- Column index.- Returns:
- Column value.
- Throws:
IndexOutOfBoundsException- If no column with the given index exists.
-
stringValue
Gets aStringcolumn 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 aStringcolumn 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 aUUIDcolumn 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 aUUIDcolumn value.- Parameters:
columnIndex- Column index.- Returns:
- Column value.
- Throws:
IndexOutOfBoundsException- If no column with the given index exists.
-
dateValue
Gets aLocalDatecolumn 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 aLocalDatecolumn value.- Parameters:
columnIndex- Column index.- Returns:
- Column value.
- Throws:
IndexOutOfBoundsException- If no column with the given index exists.
-
timeValue
Gets aLocalTimecolumn 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 aLocalTimecolumn value.- Parameters:
columnIndex- Column index.- Returns:
- Column value.
- Throws:
IndexOutOfBoundsException- If no column with the given index exists.
-
datetimeValue
Gets aLocalDateTimecolumn 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 aLocalDateTimecolumn value.- Parameters:
columnIndex- Column index.- Returns:
- Column value.
- Throws:
IndexOutOfBoundsException- If no column with the iven index exists.
-
timestampValue
Gets aInstantcolumn 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 aInstantcolumn value.- Parameters:
columnIndex- Column index.- Returns:
- Column value.
- Throws:
IndexOutOfBoundsException- If no column with the given index exists.
-
iterator
-