Package com.apple.foundationdb.tuple
Class Tuple
- java.lang.Object
-
- com.apple.foundationdb.tuple.Tuple
-
- All Implemented Interfaces:
java.lang.Comparable<Tuple>
,java.lang.Iterable<java.lang.Object>
public class Tuple extends java.lang.Object implements java.lang.Comparable<Tuple>, java.lang.Iterable<java.lang.Object>
Represents a set of elements that make up a sortable, typed key. This object is comparable with otherTuple
s and will sort in Java in the same order in which they would sort in FoundationDB.Tuple
s sort first by the first element, then by the second, etc. This makes the tuple layer ideal for building a variety of higher-level data models.
Types
ATuple
can contain byte arrays (byte[]
),String
s,Number
s,UUID
s,boolean
s,List
s,Versionstamp
s, otherTuple
s, andnull
.Float
andDouble
instances will be serialized as single- and double-precision numbers respectively, andBigInteger
s within the range [-2^2040+1
,2^2040-1
] are serialized without loss of precision (those outside the range will raise anIllegalArgumentException
). All otherNumber
s will be converted to along
integral value, so the range will be constrained to [-2^63
,2^63-1
]. Note that for numbers outside this range the way that Java truncates integral values may yield unexpected results.
The FoundationDB tuple specification has a special type-code fornull
valuesNone
;nil
; or, as Java would understand it,null
. The behavior of the layer in the presence ofnull
varies by type with the intention of matching expected behavior in Java.byte[]
,String
s,UUID
s, and nestedList
s andTuple
s can benull
, whereas numbers (e.g.,long
s anddouble
s) and booleans cannot. This means that the typed getters (getBytes()
,getString()
),getUUID()
,getNestedTuple()
,getVersionstamp
, andgetNestedList()
) will returnnull
if the entry at that location wasnull
and the typed adds (add(byte[])
,add(String)
,add(Versionstamp)
add(Tuple)
, andadd(List)
) will acceptnull
. Thetyped get for integers
and other typed getters, however, will throw aNullPointerException
if the entry in theTuple
wasnull
at that position.
This class is not thread safe.
-
-
Constructor Summary
Constructors Constructor Description Tuple()
Construct a new emptyTuple
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Tuple
add(boolean b)
Creates a copy of thisTuple
with aboolean
appended as the last element.Tuple
add(byte[] b)
Creates a copy of thisTuple
with abyte
array appended as the last element.Tuple
add(byte[] b, int offset, int length)
Creates a copy of thisTuple
with abyte
array appended as the last element.Tuple
add(double d)
Creates a copy of thisTuple
with adouble
appended as the last element.Tuple
add(float f)
Creates a copy of thisTuple
with afloat
appended as the last element.Tuple
add(long l)
Creates a copy of thisTuple
with along
appended as the last element.Tuple
add(Tuple t)
Creates a copy of thisTuple
with aTuple
appended as the last element.Tuple
add(Versionstamp v)
Creates a copy of thisTuple
with aVersionstamp
object appended as the last element.Tuple
add(java.lang.String s)
Creates a copy of thisTuple
with aString
appended as the last element.Tuple
add(java.math.BigInteger bi)
Creates a copy of thisTuple
with aBigInteger
appended as the last element.Tuple
add(java.util.List<?> l)
Creates a copy of thisTuple
with aList
appended as the last element.Tuple
add(java.util.UUID uuid)
Creates a copy of thisTuple
with aUUID
appended as the last element.Tuple
addAll(Tuple other)
Create a copy of thisTuple
with all elements from antherTuple
appended.Tuple
addAll(java.util.List<?> o)
Create a copy of thisTuple
with a list of items appended.Tuple
addObject(java.lang.Object o)
Creates a copy of thisTuple
with an appended last element.int
compareTo(Tuple t)
Compare the byte-array representation of thisTuple
against another.boolean
equals(java.lang.Object o)
Tests for equality with anotherTuple
.static Tuple
from(java.lang.Object... items)
Creates a newTuple
from a variable number of elements.static Tuple
fromBytes(byte[] bytes)
Construct a newTuple
with elements decoded from a suppliedbyte
array.static Tuple
fromBytes(byte[] bytes, int offset, int length)
Construct a newTuple
with elements decoded from a suppliedbyte
array.static Tuple
fromItems(java.lang.Iterable<?> items)
Creates a newTuple
from a variable number of elements.static Tuple
fromList(java.util.List<?> items)
Efficiently creates a newTuple
from a list of objects.static Tuple
fromStream(java.util.stream.Stream<?> items)
Efficiently creates a newTuple
from aStream
of objects.java.lang.Object
get(int index)
Gets an indexed item without forcing a type.java.math.BigInteger
getBigInteger(int index)
Gets an indexed item as aBigInteger
.boolean
getBoolean(int index)
Gets an indexed item as aboolean
.byte[]
getBytes(int index)
Gets an indexed item as abyte[]
.double
getDouble(int index)
Gets an indexed item as adouble
.float
getFloat(int index)
Gets an indexed item as afloat
.java.util.List<java.lang.Object>
getItems()
Gets the unserialized contents of thisTuple
.long
getLong(int index)
Gets an indexed item as along
.java.util.List<java.lang.Object>
getNestedList(int index)
Gets an indexed item as aList
.Tuple
getNestedTuple(int index)
Gets an indexed item as aTuple
.int
getPackedSize()
Get the number of bytes in the packed representation of thisTuple
.java.lang.String
getString(int index)
Gets an indexed item as aString
.java.util.UUID
getUUID(int index)
Gets an indexed item as aUUID
.Versionstamp
getVersionstamp(int index)
Gets an indexed item as aVersionstamp
.int
hashCode()
Returns a hash code value for thisTuple
.boolean
hasIncompleteVersionstamp()
Determines if there is aVersionstamp
included in thisTuple
that has not had its transaction version set.boolean
isEmpty()
Determine if thisTuple
contains no elements.java.util.Iterator<java.lang.Object>
iterator()
Gets anIterator
over theObjects
in thisTuple
.byte[]
pack()
Get an encoded representation of thisTuple
.byte[]
pack(byte[] prefix)
Get an encoded representation of thisTuple
.void
packInto(java.nio.ByteBuffer dest)
Pack an encoded representation of thisTuple
onto the end of the givenByteBuffer
.byte[]
packWithVersionstamp()
Get an encoded representation of thisTuple
for use withMutationType.SET_VERSIONSTAMPED_KEY
.byte[]
packWithVersionstamp(byte[] prefix)
Get an encoded representation of thisTuple
for use withMutationType.SET_VERSIONSTAMPED_KEY
.Tuple
popBack()
Creates a newTuple
with the last item of thisTuple
removed.Tuple
popFront()
Creates a newTuple
with the first item of thisTuple
removed.Range
range()
Returns a range representing all keys that encodeTuple
s strictly starting with thisTuple
.Range
range(byte[] prefix)
Returns a range representing all keys that encodeTuple
s strictly starting with the given prefix followed by thisTuple
.int
size()
Gets the number of elements in thisTuple
.java.util.stream.Stream<java.lang.Object>
stream()
Gets aStream
of the unserialized contents of thisTuple
.java.lang.String
toString()
Returns a string representing thisTuple
.
-
-
-
Constructor Detail
-
Tuple
public Tuple()
Construct a new emptyTuple
. After creation, items can be added with calls to the variations ofadd()
.- See Also:
from(Object...)
,fromBytes(byte[])
,fromItems(Iterable)
-
-
Method Detail
-
addObject
public Tuple addObject(java.lang.Object o)
Creates a copy of thisTuple
with an appended last element. The parameter is untyped but onlyString
,byte[]
,Number
s,UUID
s,Boolean
s,List
s,Tuple
s, andnull
are allowed. If an object of another type is passed, then anIllegalArgumentException
is thrown.- Parameters:
o
- the object to append. Must beString
,byte[]
,Number
s,UUID
,List
,Boolean
, ornull
.- Returns:
- a newly created
Tuple
-
add
public Tuple add(java.lang.String s)
Creates a copy of thisTuple
with aString
appended as the last element.- Parameters:
s
- theString
to append- Returns:
- a newly created
Tuple
-
add
public Tuple add(long l)
Creates a copy of thisTuple
with along
appended as the last element.- Parameters:
l
- the number to append- Returns:
- a newly created
Tuple
-
add
public Tuple add(byte[] b)
Creates a copy of thisTuple
with abyte
array appended as the last element.- Parameters:
b
- thebyte
s to append- Returns:
- a newly created
Tuple
-
add
public Tuple add(boolean b)
Creates a copy of thisTuple
with aboolean
appended as the last element.- Parameters:
b
- theboolean
to append- Returns:
- a newly created
Tuple
-
add
public Tuple add(java.util.UUID uuid)
Creates a copy of thisTuple
with aUUID
appended as the last element.- Parameters:
uuid
- theUUID
to append- Returns:
- a newly created
Tuple
-
add
public Tuple add(java.math.BigInteger bi)
Creates a copy of thisTuple
with aBigInteger
appended as the last element. AsTuple
s cannot containnull
numeric types, aNullPointerException
is raised if anull
argument is passed.- Parameters:
bi
- theBigInteger
to append- Returns:
- a newly created
Tuple
-
add
public Tuple add(float f)
Creates a copy of thisTuple
with afloat
appended as the last element.- Parameters:
f
- thefloat
to append- Returns:
- a newly created
Tuple
-
add
public Tuple add(double d)
Creates a copy of thisTuple
with adouble
appended as the last element.- Parameters:
d
- thedouble
to append- Returns:
- a newly created
Tuple
-
add
public Tuple add(Versionstamp v)
Creates a copy of thisTuple
with aVersionstamp
object appended as the last element.- Parameters:
v
- theVersionstamp
to append- Returns:
- a newly created
Tuple
-
add
public Tuple add(java.util.List<?> l)
Creates a copy of thisTuple
with aList
appended as the last element. This does not add the elements individually (for that, useTuple.addAll
). This adds the list as a single element nested within the outerTuple
.- Parameters:
l
- theList
to append- Returns:
- a newly created
Tuple
-
add
public Tuple add(Tuple t)
Creates a copy of thisTuple
with aTuple
appended as the last element. This does not add the elements individually (for that, useTuple.addAll
). This adds the list as a single element nested within the outerTuple
.- Parameters:
t
- theTuple
to append- Returns:
- a newly created
Tuple
-
add
public Tuple add(byte[] b, int offset, int length)
Creates a copy of thisTuple
with abyte
array appended as the last element.- Parameters:
b
- thebyte
s to appendoffset
- the starting index ofb
to addlength
- the number of elements ofb
to copy into thisTuple
- Returns:
- a newly created
Tuple
-
addAll
public Tuple addAll(java.util.List<?> o)
Create a copy of thisTuple
with a list of items appended.- Parameters:
o
- the list of objects to append. Elements must beString
,byte[]
,Number
s, ornull
.- Returns:
- a newly created
Tuple
-
addAll
public Tuple addAll(Tuple other)
Create a copy of thisTuple
with all elements from antherTuple
appended.- Parameters:
other
- theTuple
whose elements should be appended- Returns:
- a newly created
Tuple
-
pack
public byte[] pack()
Get an encoded representation of thisTuple
. Each element is encoded tobyte
s and concatenated. Note that once aTuple
has been packed, its serialized representation is stored internally so that future calls to this function are faster than the initial call.- Returns:
- a packed representation of this
Tuple
-
pack
public byte[] pack(byte[] prefix)
Get an encoded representation of thisTuple
. Each element is encoded tobyte
s and concatenated, and then the prefix supplied is prepended to the array. Note that once aTuple
has been packed, its serialized representation is stored internally so that future calls to this function are faster than the initial call.- Parameters:
prefix
- additional byte-array prefix to prepend to the packed bytes- Returns:
- a packed representation of this
Tuple
prepended by theprefix
-
packInto
public void packInto(java.nio.ByteBuffer dest)
Pack an encoded representation of thisTuple
onto the end of the givenByteBuffer
. It is up to the caller to ensure that there is enough space allocated within the buffer to avoidBufferOverflowException
s. The client may callgetPackedSize()
to determine how large thisTuple
will be once packed in order to allocate sufficient memory. Note that unlikepack()
, the serialized representation of thisTuple
is not stored, so calling this function multiple times with the sameTuple
requires serializing theTuple
multiple times.
This method will throw an error if there are any incompleteVersionstamp
s in thisTuple
.- Parameters:
dest
- the destinationByteBuffer
for the encodedTuple
-
packWithVersionstamp
public byte[] packWithVersionstamp()
Get an encoded representation of thisTuple
for use withMutationType.SET_VERSIONSTAMPED_KEY
. This works the same as theone-paramter version of this method
, but it does not add any prefix to the array.- Returns:
- a packed representation of this
Tuple
for use with versionstamp ops. - Throws:
java.lang.IllegalArgumentException
- if there is not exactly one incompleteVersionstamp
included in thisTuple
-
packWithVersionstamp
public byte[] packWithVersionstamp(byte[] prefix)
Get an encoded representation of thisTuple
for use withMutationType.SET_VERSIONSTAMPED_KEY
. There must be exactly one incompleteVersionstamp
instance within thisTuple
or this will throw anIllegalArgumentException
. Each element is encoded tobyte
s and concatenated, the prefix is then prepended to the array, and then the index of the packed incompleteVersionstamp
is appended as a little-endian integer. This can then be passed as the key toTransaction.mutate()
with theSET_VERSIONSTAMPED_KEY
MutationType
, and the transaction's version will then be filled in at commit time.
Note that once aTuple
has been packed, its serialized representation is stored internally so that future calls to this function are faster than the initial call.- Parameters:
prefix
- additional byte-array prefix to prepend to packed bytes.- Returns:
- a packed representation of this
Tuple
for use with versionstamp ops. - Throws:
java.lang.IllegalArgumentException
- if there is not exactly one incompleteVersionstamp
included in thisTuple
-
getItems
public java.util.List<java.lang.Object> getItems()
Gets the unserialized contents of thisTuple
.- Returns:
- the elements that make up this
Tuple
.
-
stream
public java.util.stream.Stream<java.lang.Object> stream()
Gets aStream
of the unserialized contents of thisTuple
.- Returns:
- a
Stream
of the elements that make up thisTuple
.
-
iterator
public java.util.Iterator<java.lang.Object> iterator()
Gets anIterator
over theObjects
in thisTuple
. ThisIterator
is unmodifiable and will throw an exception ifremove()
is called.- Specified by:
iterator
in interfacejava.lang.Iterable<java.lang.Object>
- Returns:
- an unmodifiable
Iterator
over the elements in theTuple
.
-
fromBytes
public static Tuple fromBytes(byte[] bytes)
Construct a newTuple
with elements decoded from a suppliedbyte
array. The passed byte array must not benull
. This will throw an exception if the passed byte array does not represent a validTuple
. For example, this will throw an error if it encounters an unknown type code or if there is a packed element that appears to be truncated.- Parameters:
bytes
- encodedTuple
source- Returns:
- a new
Tuple
constructed by deserializing the providedbyte
array - Throws:
java.lang.IllegalArgumentException
- ifbytes
does not represent a validTuple
-
fromBytes
public static Tuple fromBytes(byte[] bytes, int offset, int length)
Construct a newTuple
with elements decoded from a suppliedbyte
array. The passed byte array must not benull
. This will throw an exception if the specified slice of the passed byte array does not represent a validTuple
. For example, this will throw an error if it encounters an unknown type code or if there is a packed element that appears to be truncated.- Parameters:
bytes
- encodedTuple
sourceoffset
- starting offset of byte array of encoded datalength
- length of encoded data within the source- Returns:
- a new
Tuple
constructed by deserializing the specified slice of the providedbyte
array - Throws:
java.lang.IllegalArgumentException
- ifoffset
orlength
are negative or would exceed the size of the array or ifbytes
does not represent a validTuple
-
size
public int size()
Gets the number of elements in thisTuple
.- Returns:
- the number of elements in this
Tuple
-
isEmpty
public boolean isEmpty()
Determine if thisTuple
contains no elements.- Returns:
true
if thisTuple
contains no elements,false
otherwise
-
getLong
public long getLong(int index)
Gets an indexed item as along
. This function will not do type conversion and so will throw aClassCastException
if the element is not a number type. The element at the index may not benull
.- Parameters:
index
- the location of the item to return- Returns:
- the item at
index
as along
- Throws:
java.lang.ClassCastException
- if the element atindex
is not aNumber
java.lang.NullPointerException
- if the element atindex
isnull
-
getBytes
public byte[] getBytes(int index)
Gets an indexed item as abyte[]
. This function will not do type conversion and so will throw aClassCastException
if the tuple element is not abyte
array.- Parameters:
index
- the location of the element to return- Returns:
- the item at
index
as abyte[]
- Throws:
java.lang.ClassCastException
- if the element atindex
is not aNumber
-
getString
public java.lang.String getString(int index)
Gets an indexed item as aString
. This function will not do type conversion and so will throw aClassCastException
if the tuple element is not ofString
type.- Parameters:
index
- the location of the element to return- Returns:
- the item at
index
as aString
- Throws:
java.lang.ClassCastException
- if the element atindex
is not aString
-
getBigInteger
public java.math.BigInteger getBigInteger(int index)
Gets an indexed item as aBigInteger
. This function will not do type conversion and so will throw aClassCastException
if the tuple element is not of aNumber
type. If the underlying type is a floating point value, this will lead to a loss of precision. The element at the index may not benull
.- Parameters:
index
- the location of the element to return- Returns:
- the item at
index
as aBigInteger
- Throws:
java.lang.ClassCastException
- if the element atindex
is not aNumber
-
getFloat
public float getFloat(int index)
Gets an indexed item as afloat
. This function will not do type conversion and so will throw aClassCastException
if the element is not a number type. The element at the index may not benull
.- Parameters:
index
- the location of the item to return- Returns:
- the item at
index
as afloat
- Throws:
java.lang.ClassCastException
- if the element atindex
is not aNumber
-
getDouble
public double getDouble(int index)
Gets an indexed item as adouble
. This function will not do type conversion and so will throw aClassCastException
if the element is not a number type. The element at the index may not benull
.- Parameters:
index
- the location of the item to return- Returns:
- the item at
index
as adouble
- Throws:
java.lang.ClassCastException
- if the element atindex
is not aNumber
-
getBoolean
public boolean getBoolean(int index)
Gets an indexed item as aboolean
. This function will not do type conversion and so will throw aClassCastException
if the element is not aBoolean
. The element at the index may not benull
.- Parameters:
index
- the location of the item to return- Returns:
- the item at
index
as aboolean
- Throws:
java.lang.ClassCastException
- if the element atindex
is not aBoolean
java.lang.NullPointerException
- if the element atindex
isnull
-
getUUID
public java.util.UUID getUUID(int index)
Gets an indexed item as aUUID
. This function will not do type conversion and so will throw aClassCastException
if the element is not aUUID
. The element at the index may benull
.- Parameters:
index
- the location of the item to return- Returns:
- the item at
index
as aUUID
- Throws:
java.lang.ClassCastException
- if the element atindex
is not aUUID
-
getVersionstamp
public Versionstamp getVersionstamp(int index)
Gets an indexed item as aVersionstamp
. This function will not do type conversion and so will throw aClassCastException
if the element is not aVersionstamp
. The element at the index may benull
.- Parameters:
index
- the location of the item to return- Returns:
- the item at
index
as aVersionstamp
- Throws:
java.lang.ClassCastException
- if the element atindex
is not aVersionstamp
-
getNestedList
public java.util.List<java.lang.Object> getNestedList(int index)
Gets an indexed item as aList
. This function will not do type conversion and so will throw aClassCastException
if the element is not aList
orTuple
. The element at the index may benull
.- Parameters:
index
- the location of the item to return- Returns:
- the item at
index
as aList
- Throws:
java.lang.ClassCastException
- if the element atindex
is not aList
or aTuple
-
getNestedTuple
public Tuple getNestedTuple(int index)
Gets an indexed item as aTuple
. This function will not do type conversion and so will throw aClassCastException
if the element is not aList
orTuple
. The element at the index may benull
.- Parameters:
index
- the location of the item to return- Returns:
- the item at
index
as aList
- Throws:
java.lang.ClassCastException
- if the element atindex
is not aTuple
or aList
-
get
public java.lang.Object get(int index)
Gets an indexed item without forcing a type.- Parameters:
index
- the index of the item to return- Returns:
- an item from the list, without forcing type conversion
-
popFront
public Tuple popFront()
Creates a newTuple
with the first item of thisTuple
removed.- Returns:
- a newly created
Tuple
without the first item of thisTuple
- Throws:
java.lang.IllegalStateException
- if thisTuple
is empty
-
popBack
public Tuple popBack()
Creates a newTuple
with the last item of thisTuple
removed.- Returns:
- a newly created
Tuple
without the last item of thisTuple
- Throws:
java.lang.IllegalStateException
- if thisTuple
is empty
-
range
public Range range()
Returns a range representing all keys that encodeTuple
s strictly starting with thisTuple
.
For example:Tuple t = Tuple.from("a", "b"); Range r = t.range();
r
includes all tuples ("a", "b", ...)
This function will throw an error if thisTuple
contains an incompleteVersionstamp
.- Returns:
- the range of keys containing all possible keys that have this
Tuple
as a strict prefix
-
range
public Range range(byte[] prefix)
Returns a range representing all keys that encodeTuple
s strictly starting with the given prefix followed by thisTuple
.
For example:Tuple t = Tuple.from("a", "b"); Range r = t.range(Tuple.from("c").pack());
r
contains all tuples ("c", "a", "b", ...)
This function will throw an error if thisTuple
contains an incompleteVersionstamp
.- Parameters:
prefix
- a byte prefix to precede all elements in the range- Returns:
- the range of keys containing all possible keys that have
prefix
followed by thisTuple
as a strict prefix
-
hasIncompleteVersionstamp
public boolean hasIncompleteVersionstamp()
Determines if there is aVersionstamp
included in thisTuple
that has not had its transaction version set. It will search through nestedTuple
s contained within thisTuple
. It will not throw an error if it finds multiple incompleteVersionstamp
instances.- Returns:
- whether there is at least one incomplete
Versionstamp
included in thisTuple
-
getPackedSize
public int getPackedSize()
Get the number of bytes in the packed representation of thisTuple
. This is done by summing the serialized sizes of all of the elements of thisTuple
and does not pack everything into a singleTuple
. The return value of this function is stored within thisTuple
after this function has been called so that subsequent calls on the same object are fast. This method does not validate that there is not more than one incompleteVersionstamp
in thisTuple
.- Returns:
- the number of bytes in the packed representation of this
Tuple
-
compareTo
public int compareTo(Tuple t)
Compare the byte-array representation of thisTuple
against another. This method will sortTuple
s in the same order that they would be sorted as keys in FoundationDB. Returns a negative integer, zero, or a positive integer when this object's byte-array representation is found to be less than, equal to, or greater than the specifiedTuple
.- Specified by:
compareTo
in interfacejava.lang.Comparable<Tuple>
- Parameters:
t
- theTuple
against which to compare- Returns:
- a negative integer, zero, or a positive integer when this
Tuple
is less than, equal, or greater than the parametert
.
-
hashCode
public int hashCode()
Returns a hash code value for thisTuple
. Computing the hash code is fairly expensive as it involves packing the underlyingTuple
to bytes. However, this value is memoized, so for any givenTuple
, it only needs to be computed once. This means that it is generally safe to useTuple
s with hash-based data structures such asHashSet
s orHashMap
s.- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- a hash code for this
Tuple
that can be used by hash tables
-
equals
public boolean equals(java.lang.Object o)
Tests for equality with anotherTuple
. If the passed object is not aTuple
this returns false. If the object is aTuple
, this returns true ifcompareTo()
would return0
.- Overrides:
equals
in classjava.lang.Object
- Returns:
true
ifobj
is aTuple
and their binary representation is identical
-
toString
public java.lang.String toString()
Returns a string representing thisTuple
. This contains human-readable representations of all of the elements of thisTuple
. For most elements, this means using that object's default string representation. For byte-arrays, this means usingByteArrayUtil.printable()
to produce a byte-string where most printable ASCII code points have been rendered as characters.- Overrides:
toString
in classjava.lang.Object
- Returns:
- a human-readable
String
representation of thisTuple
-
fromItems
public static Tuple fromItems(java.lang.Iterable<?> items)
Creates a newTuple
from a variable number of elements. The elements must follow the type guidelines fromadd
, and so can only beString
s,byte[]
s,Number
s,UUID
s,Boolean
s,List
s,Tuple
s, ornull
s.- Parameters:
items
- the elements from which to create theTuple
- Returns:
- a new
Tuple
with the given items as its elements
-
fromList
public static Tuple fromList(java.util.List<?> items)
Efficiently creates a newTuple
from a list of objects. The elements must follow the type guidelines fromadd
, and so can only beString
s,byte[]
s,Number
s,UUID
s,Boolean
s,List
s,Tuple
s, ornull
s.- Parameters:
items
- the elements from which to create theTuple
.- Returns:
- a new
Tuple
with the given items as its elements
-
fromStream
public static Tuple fromStream(java.util.stream.Stream<?> items)
Efficiently creates a newTuple
from aStream
of objects. The elements must follow the type guidelines fromadd
, and so can only beString
s,byte[]
s,Number
s,UUID
s,Boolean
s,List
s,Tuple
s, ornull
s. Note that this class will consume all elements from theStream
.- Parameters:
items
- theStream
of items from which to create theTuple
- Returns:
- a new
Tuple
with the given items as its elements
-
from
public static Tuple from(java.lang.Object... items)
Creates a newTuple
from a variable number of elements. The elements must follow the type guidelines fromadd
, and so can only beString
s,byte[]
s,Number
s,UUID
s,Boolean
s,List
s,Tuple
s, ornull
s.- Parameters:
items
- the elements from which to create theTuple
- Returns:
- a new
Tuple
with the given items as its elements
-
-