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 ofTarantoolTuplefrom a list of objectsTarantoolTupleImpl(Collection<?> values, MessagePackMapper mapper, TarantoolSpaceMetadata metadata)Construct an instance ofTarantoolTuplefrom a list of objects.TarantoolTupleImpl(org.msgpack.value.ArrayValue value, MessagePackMapper mapper)Construct an instance ofTarantoolTupleTarantoolTupleImpl(org.msgpack.value.ArrayValue value, MessagePackMapper mapper, TarantoolSpaceMetadata spaceMetadata)Basic constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancanGetObject(int fieldPosition, Class<?> objectClass)Check if a tuple field exists and can be converted to the target value typebooleancanGetObject(String fieldName, Class<?> objectClass)Check if a tuple field exists and can be converted to the target value typebooleanequals(Object o)voidforEach(Consumer<? super TarantoolField> action)BooleangetBoolean(int fieldPosition)Get the field value converted toBooleanBooleangetBoolean(String fieldName)Get the field value converted toBooleanbyte[]getByteArray(int fieldPosition)Get the field value converted tobyte[]byte[]getByteArray(String fieldName)Get the field value converted tobyte[]CharactergetCharacter(int fieldPosition)Get the field value converted toCharacterCharactergetCharacter(String fieldName)Get the field value converted toCharacterBigDecimalgetDecimal(int fieldPosition)Get the field value converted toBigDecimalBigDecimalgetDecimal(String fieldName)Get the field value converted toBigDecimalDoublegetDouble(int fieldPosition)Get the field value converted toDoubleDoublegetDouble(String fieldName)Get the field value converted toDoubleOptional<TarantoolField>getField(int fieldPosition)Get a tuple field by its positionOptional<TarantoolField>getField(String fieldName)Get a tuple field by its nameprotected intgetFieldPositionByName(String fieldName)List<TarantoolField>getFields()Get all tuple fields as listFloatgetFloat(int fieldPosition)Get the field value converted toFloatFloatgetFloat(String fieldName)Get the field value converted toFloatIntegergetInteger(int fieldPosition)Get the field value converted toIntegerIntegergetInteger(String fieldName)Get the field value converted toIntegerList<?>getList(int fieldPosition)Get the field value converted toListList<?>getList(String fieldName)Get the field value converted toListLonggetLong(int fieldPosition)Get the field value converted toLongLonggetLong(String fieldName)Get the field value converted toLongMap<?,?>getMap(int fieldPosition)Get the field value converted toMapMap<?,?>getMap(String fieldName)Get the field value converted toMapOptional<?>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 typeStringgetString(int fieldPosition)Get the field value converted toStringStringgetString(String fieldName)Get the field value converted toStringUUIDgetUUID(int fieldPosition)Get the field value converted toUUIDUUIDgetUUID(String fieldName)Get the field value converted toUUIDinthashCode()Iterator<TarantoolField>iterator()voidputObject(int fieldPosition, Object value)Set a tuple field value from an object by field positionvoidputObject(String fieldName, Object value)Set a tuple field value from an object by field namevoidsetField(int fieldPosition, TarantoolField field)Set a tuple field by field positionvoidsetField(String fieldName, TarantoolField field)Set a tuple field by field nameintsize()Get the number of fields in this tupleSpliterator<TarantoolField>spliterator()org.msgpack.value.ValuetoMessagePackValue(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 ofTarantoolTuplefrom 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 ofTarantoolTuplefrom 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:TarantoolTupleGet a tuple field by its position- Specified by:
getFieldin 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:TarantoolTupleGet a tuple field by its name- Specified by:
getFieldin 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:TarantoolTupleGet all tuple fields as list- Specified by:
getFieldsin interfaceTarantoolTuple- Returns:
- all tuple fields as list
-
getObject
public <O> Optional<O> getObject(int fieldPosition, Class<O> objectClass)
Description copied from interface:TarantoolTupleGet a tuple field value by its position specifying the target value type- Specified by:
getObjectin 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:TarantoolTupleCheck if a tuple field exists and can be converted to the target value type- Specified by:
canGetObjectin 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:TarantoolTupleGet a tuple field value by its name specifying the target value type- Specified by:
getObjectin 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:TarantoolTupleCheck if a tuple field exists and can be converted to the target value type- Specified by:
canGetObjectin 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:TarantoolTupleGet a tuple field value as a raw object- Specified by:
getObjectin 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:TarantoolTupleGet a tuple field value as a raw object- Specified by:
getObjectin 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:
iteratorin interfaceIterable<TarantoolField>
-
forEach
public void forEach(Consumer<? super TarantoolField> action)
- Specified by:
forEachin interfaceIterable<TarantoolField>
-
spliterator
public Spliterator<TarantoolField> spliterator()
- Specified by:
spliteratorin interfaceIterable<TarantoolField>
-
toMessagePackValue
public org.msgpack.value.Value toMessagePackValue(MessagePackObjectMapper mapper)
Description copied from interface:PackableConvert this instance into a corresponding MessagePackValue- Specified by:
toMessagePackValuein interfacePackable- Parameters:
mapper- configured Java objects to entities mapper- Returns:
- MessagePack entity
-
size
public int size()
Description copied from interface:TarantoolTupleGet the number of fields in this tuple- Specified by:
sizein interfaceTarantoolTuple- Returns:
- the number of fields in this tuple
-
setField
public void setField(int fieldPosition, TarantoolField field)Description copied from interface:TarantoolTupleSet a tuple field by field position- Specified by:
setFieldin 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:TarantoolTupleSet a tuple field by field name- Specified by:
setFieldin interfaceTarantoolTuple- Parameters:
fieldName- the field name, must be not nullfield- new field
-
putObject
public void putObject(int fieldPosition, Object value)Description copied from interface:TarantoolTupleSet a tuple field value from an object by field position- Specified by:
putObjectin 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:TarantoolTupleSet a tuple field value from an object by field name- Specified by:
putObjectin interfaceTarantoolTuple- Parameters:
fieldName- the field name, must not be nullvalue- new field value
-
getByteArray
public byte[] getByteArray(int fieldPosition)
Description copied from interface:TarantoolTupleGet the field value converted tobyte[]- Specified by:
getByteArrayin 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:TarantoolTupleGet the field value converted tobyte[]- Specified by:
getByteArrayin interfaceTarantoolTuple- Parameters:
fieldName- the field name, must not be null- Returns:
- value
-
getBoolean
public Boolean getBoolean(int fieldPosition)
Description copied from interface:TarantoolTupleGet the field value converted toBoolean- Specified by:
getBooleanin 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:TarantoolTupleGet the field value converted toBoolean- Specified by:
getBooleanin interfaceTarantoolTuple- Parameters:
fieldName- the field name, must not be null- Returns:
- value
-
getDouble
public Double getDouble(int fieldPosition)
Description copied from interface:TarantoolTupleGet the field value converted toDouble- Specified by:
getDoublein 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:TarantoolTupleGet the field value converted toDouble- Specified by:
getDoublein interfaceTarantoolTuple- Parameters:
fieldName- the field name, must not be null- Returns:
- value
-
getFloat
public Float getFloat(int fieldPosition)
Description copied from interface:TarantoolTupleGet the field value converted toFloat- Specified by:
getFloatin 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:TarantoolTupleGet the field value converted toFloat- Specified by:
getFloatin interfaceTarantoolTuple- Parameters:
fieldName- the field name, must not be null- Returns:
- value
-
getInteger
public Integer getInteger(int fieldPosition)
Description copied from interface:TarantoolTupleGet the field value converted toInteger- Specified by:
getIntegerin 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:TarantoolTupleGet the field value converted toInteger- Specified by:
getIntegerin interfaceTarantoolTuple- Parameters:
fieldName- the field name, must not be null- Returns:
- value
-
getLong
public Long getLong(int fieldPosition)
Description copied from interface:TarantoolTupleGet the field value converted toLong- Specified by:
getLongin 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:TarantoolTupleGet the field value converted toLong- Specified by:
getLongin interfaceTarantoolTuple- Parameters:
fieldName- the field name, must not be null- Returns:
- value
-
getString
public String getString(int fieldPosition)
Description copied from interface:TarantoolTupleGet the field value converted toString- Specified by:
getStringin 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:TarantoolTupleGet the field value converted toString- Specified by:
getStringin interfaceTarantoolTuple- Parameters:
fieldName- the field name, must not be null- Returns:
- value
-
getCharacter
public Character getCharacter(int fieldPosition)
Description copied from interface:TarantoolTupleGet the field value converted toCharacter- Specified by:
getCharacterin 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:TarantoolTupleGet the field value converted toCharacter- Specified by:
getCharacterin interfaceTarantoolTuple- Parameters:
fieldName- the field name, must not be null- Returns:
- value
-
getUUID
public UUID getUUID(int fieldPosition)
Description copied from interface:TarantoolTupleGet the field value converted toUUID- Specified by:
getUUIDin 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:TarantoolTupleGet the field value converted toUUID- Specified by:
getUUIDin interfaceTarantoolTuple- Parameters:
fieldName- the field name, must not be null- Returns:
- value
-
getDecimal
public BigDecimal getDecimal(int fieldPosition)
Description copied from interface:TarantoolTupleGet the field value converted toBigDecimal- Specified by:
getDecimalin 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:TarantoolTupleGet the field value converted toBigDecimal- Specified by:
getDecimalin interfaceTarantoolTuple- Parameters:
fieldName- the field name, must not be null- Returns:
- value
-
getList
public List<?> getList(int fieldPosition)
Description copied from interface:TarantoolTupleGet the field value converted toList- Specified by:
getListin 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:TarantoolTupleGet the field value converted toList- Specified by:
getListin interfaceTarantoolTuple- Parameters:
fieldName- the field name, must not be null- Returns:
- value
-
getMap
public Map<?,?> getMap(int fieldPosition)
Description copied from interface:TarantoolTupleGet the field value converted toMap- Specified by:
getMapin 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:TarantoolTupleGet the field value converted toMap- Specified by:
getMapin interfaceTarantoolTuple- Parameters:
fieldName- the field name, must not be null- Returns:
- value
-
getFieldPositionByName
protected int getFieldPositionByName(String fieldName)
-
-