Package io.tarantool.driver.core.tuple
Class TarantoolTupleImpl
- java.lang.Object
-
- io.tarantool.driver.core.tuple.TarantoolTupleImpl
-
- All Implemented Interfaces:
TarantoolTuple
,Packable
,Serializable
,Iterable<TarantoolField>
public class TarantoolTupleImpl extends Object implements TarantoolTuple
Basic Tarantool tuple implementation- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description TarantoolTupleImpl(MessagePackMapper mapper)
Constructor for empty tupleTarantoolTupleImpl(MessagePackMapper mapper, TarantoolSpaceMetadata metadata)
Constructor for empty tuple with metadataTarantoolTupleImpl(Collection<?> values, MessagePackMapper mapper)
Construct an instance ofTarantoolTuple
from a list of objectsTarantoolTupleImpl(Collection<?> values, MessagePackMapper mapper, TarantoolSpaceMetadata metadata)
Construct an instance ofTarantoolTuple
from a list of objects.TarantoolTupleImpl(org.msgpack.value.ArrayValue value, MessagePackMapper mapper)
Construct an instance ofTarantoolTuple
TarantoolTupleImpl(org.msgpack.value.ArrayValue value, MessagePackMapper mapper, TarantoolSpaceMetadata spaceMetadata)
Basic constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
canGetObject(int fieldPosition, Class<?> objectClass)
Check if a tuple field exists and can be converted to the target value typeboolean
canGetObject(String fieldName, Class<?> objectClass)
Check if a tuple field exists and can be converted to the target value typeboolean
equals(Object o)
void
forEach(Consumer<? super TarantoolField> action)
Boolean
getBoolean(int fieldPosition)
Get the field value converted toBoolean
Boolean
getBoolean(String fieldName)
Get the field value converted toBoolean
byte[]
getByteArray(int fieldPosition)
Get the field value converted tobyte[]
byte[]
getByteArray(String fieldName)
Get the field value converted tobyte[]
Character
getCharacter(int fieldPosition)
Get the field value converted toCharacter
Character
getCharacter(String fieldName)
Get the field value converted toCharacter
BigDecimal
getDecimal(int fieldPosition)
Get the field value converted toBigDecimal
BigDecimal
getDecimal(String fieldName)
Get the field value converted toBigDecimal
Double
getDouble(int fieldPosition)
Get the field value converted toDouble
Double
getDouble(String fieldName)
Get the field value converted toDouble
Optional<TarantoolField>
getField(int fieldPosition)
Get a tuple field by its positionOptional<TarantoolField>
getField(String fieldName)
Get a tuple field by its nameprotected int
getFieldPositionByName(String fieldName)
List<TarantoolField>
getFields()
Get all tuple fields as listFloat
getFloat(int fieldPosition)
Get the field value converted toFloat
Float
getFloat(String fieldName)
Get the field value converted toFloat
Integer
getInteger(int fieldPosition)
Get the field value converted toInteger
Integer
getInteger(String fieldName)
Get the field value converted toInteger
List<?>
getList(int fieldPosition)
Get the field value converted toList
List<?>
getList(String fieldName)
Get the field value converted toList
Long
getLong(int fieldPosition)
Get the field value converted toLong
Long
getLong(String fieldName)
Get the field value converted toLong
Map<?,?>
getMap(int fieldPosition)
Get the field value converted toMap
Map<?,?>
getMap(String fieldName)
Get the field value converted toMap
Optional<?>
getObject(int fieldPosition)
Get a tuple field value as a raw object<O> Optional<O>
getObject(int fieldPosition, Class<O> objectClass)
Get a tuple field value by its position specifying the target value typeOptional<?>
getObject(String fieldName)
Get a tuple field value as a raw object<O> Optional<O>
getObject(String fieldName, Class<O> objectClass)
Get a tuple field value by its name specifying the target value typeString
getString(int fieldPosition)
Get the field value converted toString
String
getString(String fieldName)
Get the field value converted toString
UUID
getUUID(int fieldPosition)
Get the field value converted toUUID
UUID
getUUID(String fieldName)
Get the field value converted toUUID
int
hashCode()
Iterator<TarantoolField>
iterator()
void
putObject(int fieldPosition, Object value)
Set a tuple field value from an object by field positionvoid
putObject(String fieldName, Object value)
Set a tuple field value from an object by field namevoid
setField(int fieldPosition, TarantoolField field)
Set a tuple field by field positionvoid
setField(String fieldName, TarantoolField field)
Set a tuple field by field nameint
size()
Get the number of fields in this tupleSpliterator<TarantoolField>
spliterator()
org.msgpack.value.Value
toMessagePackValue(MessagePackObjectMapper mapper)
Convert this instance into a corresponding MessagePackValue
-
-
-
Constructor Detail
-
TarantoolTupleImpl
public TarantoolTupleImpl(MessagePackMapper mapper)
Constructor for empty tuple- Parameters:
mapper
- provides conversion between MessagePack values and Java objects
-
TarantoolTupleImpl
public TarantoolTupleImpl(MessagePackMapper mapper, TarantoolSpaceMetadata metadata)
Constructor for empty tuple with metadata- Parameters:
mapper
- provides conversion between MessagePack values and Java objectsmetadata
- provides information about the target space
-
TarantoolTupleImpl
public TarantoolTupleImpl(Collection<?> values, MessagePackMapper mapper)
Construct an instance ofTarantoolTuple
from a list of objects- Parameters:
values
- list of tuple fields datamapper
- provides conversion between MessagePack values and Java objects
-
TarantoolTupleImpl
public TarantoolTupleImpl(Collection<?> values, MessagePackMapper mapper, TarantoolSpaceMetadata metadata)
Construct an instance ofTarantoolTuple
from a list of objects. Provides space metadata which adds extra functionality for working with fields and indexes.- Parameters:
values
- list of tuple fields datamapper
- provides conversion between MessagePack values and Java objectsmetadata
- provides information about the target space
-
TarantoolTupleImpl
public TarantoolTupleImpl(org.msgpack.value.ArrayValue value, MessagePackMapper mapper)
Construct an instance ofTarantoolTuple
- Parameters:
value
- serialized Tarantool tuplemapper
- provides conversion between MessagePack values and Java objects
-
TarantoolTupleImpl
public TarantoolTupleImpl(org.msgpack.value.ArrayValue value, MessagePackMapper mapper, TarantoolSpaceMetadata spaceMetadata)
Basic constructor. Used for converting Tarantool server responses into Java entities.- Parameters:
value
- serialized Tarantool tuplemapper
- provides conversion between MessagePack values and Java objectsspaceMetadata
- provides field names and other metadata
-
-
Method Detail
-
getField
public Optional<TarantoolField> getField(int fieldPosition)
Description copied from interface:TarantoolTuple
Get a tuple field by its position- Specified by:
getField
in interfaceTarantoolTuple
- Parameters:
fieldPosition
- the field position from the the tuple start, starting from 0- Returns:
- field or empty optional if the field position is out of tuple length
-
getField
public Optional<TarantoolField> getField(String fieldName)
Description copied from interface:TarantoolTuple
Get a tuple field by its name- Specified by:
getField
in interfaceTarantoolTuple
- Parameters:
fieldName
- the field name in space- Returns:
- field or empty optional if the field not exist in space
-
getFields
public List<TarantoolField> getFields()
Description copied from interface:TarantoolTuple
Get all tuple fields as list- Specified by:
getFields
in interfaceTarantoolTuple
- Returns:
- all tuple fields as list
-
getObject
public <O> Optional<O> getObject(int fieldPosition, Class<O> objectClass)
Description copied from interface:TarantoolTuple
Get a tuple field value by its position specifying the target value type- Specified by:
getObject
in interfaceTarantoolTuple
- Type Parameters:
O
- target value type- Parameters:
fieldPosition
- field position from the the tuple start, starting from 0objectClass
- target value type class- Returns:
- nullable value of a field wrapped in Optional, possibly converted to a Java type
-
canGetObject
public boolean canGetObject(int fieldPosition, Class<?> objectClass)
Description copied from interface:TarantoolTuple
Check if a tuple field exists and can be converted to the target value type- Specified by:
canGetObject
in interfaceTarantoolTuple
- Parameters:
fieldPosition
- field position from the the tuple start, starting from 0objectClass
- target value type class- Returns:
- true, if the field exists and can be converted to the given type, false otherwise
-
getObject
public <O> Optional<O> getObject(String fieldName, Class<O> objectClass)
Description copied from interface:TarantoolTuple
Get a tuple field value by its name specifying the target value type- Specified by:
getObject
in interfaceTarantoolTuple
- Type Parameters:
O
- target value type- Parameters:
fieldName
- field name, should not be nullobjectClass
- target value type class- Returns:
- nullable value of a field wrapped in Optional, possibly converted to a Java type
-
canGetObject
public boolean canGetObject(String fieldName, Class<?> objectClass)
Description copied from interface:TarantoolTuple
Check if a tuple field exists and can be converted to the target value type- Specified by:
canGetObject
in interfaceTarantoolTuple
- Parameters:
fieldName
- field name, should not be nullobjectClass
- target value type class- Returns:
- true, if the field exists and can be converted to the given type, false otherwise
-
getObject
public Optional<?> getObject(int fieldPosition)
Description copied from interface:TarantoolTuple
Get a tuple field value as a raw object- Specified by:
getObject
in interfaceTarantoolTuple
- Parameters:
fieldPosition
- field position from the the tuple start, starting from 0- Returns:
- nullable value of a field wrapped in Optional
-
getObject
public Optional<?> getObject(String fieldName)
Description copied from interface:TarantoolTuple
Get a tuple field value as a raw object- Specified by:
getObject
in interfaceTarantoolTuple
- Parameters:
fieldName
- field name, should not be null- Returns:
- nullable value of a field wrapped in Optional
-
iterator
public Iterator<TarantoolField> iterator()
- Specified by:
iterator
in interfaceIterable<TarantoolField>
-
forEach
public void forEach(Consumer<? super TarantoolField> action)
- Specified by:
forEach
in interfaceIterable<TarantoolField>
-
spliterator
public Spliterator<TarantoolField> spliterator()
- Specified by:
spliterator
in interfaceIterable<TarantoolField>
-
toMessagePackValue
public org.msgpack.value.Value toMessagePackValue(MessagePackObjectMapper mapper)
Description copied from interface:Packable
Convert this instance into a corresponding MessagePackValue
- Specified by:
toMessagePackValue
in interfacePackable
- Parameters:
mapper
- configured Java objects to entities mapper- Returns:
- MessagePack entity
-
size
public int size()
Description copied from interface:TarantoolTuple
Get the number of fields in this tuple- Specified by:
size
in interfaceTarantoolTuple
- Returns:
- the number of fields in this tuple
-
setField
public void setField(int fieldPosition, TarantoolField field)
Description copied from interface:TarantoolTuple
Set a tuple field by field position- Specified by:
setField
in interfaceTarantoolTuple
- Parameters:
fieldPosition
- the field position from the the tuple start, starting from 0field
- new field
-
setField
public void setField(String fieldName, TarantoolField field)
Description copied from interface:TarantoolTuple
Set a tuple field by field name- Specified by:
setField
in interfaceTarantoolTuple
- Parameters:
fieldName
- the field name, must be not nullfield
- new field
-
putObject
public void putObject(int fieldPosition, Object value)
Description copied from interface:TarantoolTuple
Set a tuple field value from an object by field position- Specified by:
putObject
in interfaceTarantoolTuple
- Parameters:
fieldPosition
- the field position from the the tuple start, starting from 0value
- new field value
-
putObject
public void putObject(String fieldName, Object value)
Description copied from interface:TarantoolTuple
Set a tuple field value from an object by field name- Specified by:
putObject
in interfaceTarantoolTuple
- Parameters:
fieldName
- the field name, must not be nullvalue
- new field value
-
getByteArray
public byte[] getByteArray(int fieldPosition)
Description copied from interface:TarantoolTuple
Get the field value converted tobyte[]
- Specified by:
getByteArray
in interfaceTarantoolTuple
- Parameters:
fieldPosition
- the field position from the the tuple start, starting from 0- Returns:
- value
-
getByteArray
public byte[] getByteArray(String fieldName)
Description copied from interface:TarantoolTuple
Get the field value converted tobyte[]
- Specified by:
getByteArray
in interfaceTarantoolTuple
- Parameters:
fieldName
- the field name, must not be null- Returns:
- value
-
getBoolean
public Boolean getBoolean(int fieldPosition)
Description copied from interface:TarantoolTuple
Get the field value converted toBoolean
- Specified by:
getBoolean
in interfaceTarantoolTuple
- Parameters:
fieldPosition
- the field position from the the tuple start, starting from 0- Returns:
- value
-
getBoolean
public Boolean getBoolean(String fieldName)
Description copied from interface:TarantoolTuple
Get the field value converted toBoolean
- Specified by:
getBoolean
in interfaceTarantoolTuple
- Parameters:
fieldName
- the field name, must not be null- Returns:
- value
-
getDouble
public Double getDouble(int fieldPosition)
Description copied from interface:TarantoolTuple
Get the field value converted toDouble
- Specified by:
getDouble
in interfaceTarantoolTuple
- Parameters:
fieldPosition
- the field position from the the tuple start, starting from 0- Returns:
- value
-
getDouble
public Double getDouble(String fieldName)
Description copied from interface:TarantoolTuple
Get the field value converted toDouble
- Specified by:
getDouble
in interfaceTarantoolTuple
- Parameters:
fieldName
- the field name, must not be null- Returns:
- value
-
getFloat
public Float getFloat(int fieldPosition)
Description copied from interface:TarantoolTuple
Get the field value converted toFloat
- Specified by:
getFloat
in interfaceTarantoolTuple
- Parameters:
fieldPosition
- the field position from the the tuple start, starting from 0- Returns:
- value
-
getFloat
public Float getFloat(String fieldName)
Description copied from interface:TarantoolTuple
Get the field value converted toFloat
- Specified by:
getFloat
in interfaceTarantoolTuple
- Parameters:
fieldName
- the field name, must not be null- Returns:
- value
-
getInteger
public Integer getInteger(int fieldPosition)
Description copied from interface:TarantoolTuple
Get the field value converted toInteger
- Specified by:
getInteger
in interfaceTarantoolTuple
- Parameters:
fieldPosition
- the field position from the the tuple start, starting from 0- Returns:
- value
-
getInteger
public Integer getInteger(String fieldName)
Description copied from interface:TarantoolTuple
Get the field value converted toInteger
- Specified by:
getInteger
in interfaceTarantoolTuple
- Parameters:
fieldName
- the field name, must not be null- Returns:
- value
-
getLong
public Long getLong(int fieldPosition)
Description copied from interface:TarantoolTuple
Get the field value converted toLong
- Specified by:
getLong
in interfaceTarantoolTuple
- Parameters:
fieldPosition
- the field position from the the tuple start, starting from 0- Returns:
- value
-
getLong
public Long getLong(String fieldName)
Description copied from interface:TarantoolTuple
Get the field value converted toLong
- Specified by:
getLong
in interfaceTarantoolTuple
- Parameters:
fieldName
- the field name, must not be null- Returns:
- value
-
getString
public String getString(int fieldPosition)
Description copied from interface:TarantoolTuple
Get the field value converted toString
- Specified by:
getString
in interfaceTarantoolTuple
- Parameters:
fieldPosition
- the field position from the the tuple start, starting from 0- Returns:
- value
-
getString
public String getString(String fieldName)
Description copied from interface:TarantoolTuple
Get the field value converted toString
- Specified by:
getString
in interfaceTarantoolTuple
- Parameters:
fieldName
- the field name, must not be null- Returns:
- value
-
getCharacter
public Character getCharacter(int fieldPosition)
Description copied from interface:TarantoolTuple
Get the field value converted toCharacter
- Specified by:
getCharacter
in interfaceTarantoolTuple
- Parameters:
fieldPosition
- the field position from the the tuple start, starting from 0- Returns:
- value
-
getCharacter
public Character getCharacter(String fieldName)
Description copied from interface:TarantoolTuple
Get the field value converted toCharacter
- Specified by:
getCharacter
in interfaceTarantoolTuple
- Parameters:
fieldName
- the field name, must not be null- Returns:
- value
-
getUUID
public UUID getUUID(int fieldPosition)
Description copied from interface:TarantoolTuple
Get the field value converted toUUID
- Specified by:
getUUID
in interfaceTarantoolTuple
- Parameters:
fieldPosition
- the field position from the the tuple start, starting from 0- Returns:
- value
-
getUUID
public UUID getUUID(String fieldName)
Description copied from interface:TarantoolTuple
Get the field value converted toUUID
- Specified by:
getUUID
in interfaceTarantoolTuple
- Parameters:
fieldName
- the field name, must not be null- Returns:
- value
-
getDecimal
public BigDecimal getDecimal(int fieldPosition)
Description copied from interface:TarantoolTuple
Get the field value converted toBigDecimal
- Specified by:
getDecimal
in interfaceTarantoolTuple
- Parameters:
fieldPosition
- the field position from the the tuple start, starting from 0- Returns:
- value
-
getDecimal
public BigDecimal getDecimal(String fieldName)
Description copied from interface:TarantoolTuple
Get the field value converted toBigDecimal
- Specified by:
getDecimal
in interfaceTarantoolTuple
- Parameters:
fieldName
- the field name, must not be null- Returns:
- value
-
getList
public List<?> getList(int fieldPosition)
Description copied from interface:TarantoolTuple
Get the field value converted toList
- Specified by:
getList
in interfaceTarantoolTuple
- Parameters:
fieldPosition
- the field position from the the tuple start, starting from 0- Returns:
- value
-
getList
public List<?> getList(String fieldName)
Description copied from interface:TarantoolTuple
Get the field value converted toList
- Specified by:
getList
in interfaceTarantoolTuple
- Parameters:
fieldName
- the field name, must not be null- Returns:
- value
-
getMap
public Map<?,?> getMap(int fieldPosition)
Description copied from interface:TarantoolTuple
Get the field value converted toMap
- Specified by:
getMap
in interfaceTarantoolTuple
- Parameters:
fieldPosition
- the field position from the the tuple start, starting from 0- Returns:
- value
-
getMap
public Map<?,?> getMap(String fieldName)
Description copied from interface:TarantoolTuple
Get the field value converted toMap
- Specified by:
getMap
in interfaceTarantoolTuple
- Parameters:
fieldName
- the field name, must not be null- Returns:
- value
-
getFieldPositionByName
protected int getFieldPositionByName(String fieldName)
-
-