Skip to content

Commit

Permalink
Add interval converters
Browse files Browse the repository at this point in the history
Closes #434
  • Loading branch information
ArtDu committed Nov 28, 2023
1 parent dd694c9 commit 190f7c8
Show file tree
Hide file tree
Showing 10 changed files with 640 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## [Unreleased]

### Features

- Add Interval type support ([#447](https://github.com/tarantool/cartridge-java/issues/447))

## [0.13.0] - 2023-11-16

### Internal and API changes
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/io/tarantool/driver/api/tuple/TarantoolTuple.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.util.Optional;
import java.util.UUID;

import io.tarantool.driver.mappers.converters.Interval;
import io.tarantool.driver.protocol.Packable;

/**
Expand Down Expand Up @@ -298,6 +299,22 @@ public interface TarantoolTuple extends Iterable<TarantoolField>, Packable {
*/
Instant getInstant(String fieldName);

/**
* Get the field value converted to {@link Interval}
*
* @param fieldPosition the field position from the tuple start, starting from 0
* @return value
*/
Interval getInterval(int fieldPosition);

/**
* Get the field value converted to {@link Interval}
*
* @param fieldName the field name, must not be null
* @return value
*/
Interval getInterval(String fieldName);

/**
* Get the field value converted to {@link BigDecimal}
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import io.tarantool.driver.exceptions.TarantoolSpaceFieldNotFoundException;
import io.tarantool.driver.mappers.MessagePackMapper;
import io.tarantool.driver.mappers.MessagePackObjectMapper;
import io.tarantool.driver.mappers.converters.Interval;
import io.tarantool.driver.utils.Assert;

/**
Expand Down Expand Up @@ -380,6 +381,16 @@ public Instant getInstant(String fieldName) {
return getObject(fieldName, Instant.class).orElse(null);
}

@Override
public Interval getInterval(int fieldPosition) {
return getObject(fieldPosition, Interval.class).orElse(null);
}

@Override
public Interval getInterval(String fieldName) {
return getObject(fieldName, Interval.class).orElse(null);
}

@Override
public BigDecimal getDecimal(int fieldPosition) {
return getObject(fieldPosition, BigDecimal.class).orElse(null);
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/io/tarantool/driver/mappers/converters/Adjust.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package io.tarantool.driver.mappers.converters;

/**
* @author Artyom Dubinin
*/
public enum Adjust {
NoneAdjust,
ExcessAdjust,
LastAdjust
}
Loading

0 comments on commit 190f7c8

Please sign in to comment.