Adding handling for Optional (#33)

* Adding handling for Optional in dev.vality.geck.serializer.kit.tbase.TBaseProcessor#process()

* Bump geck version
This commit is contained in:
Margarita 2024-08-16 11:00:16 +03:00 committed by GitHub
parent 522cf211f8
commit b2e1f094dd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 13 additions and 9 deletions

View File

@ -7,7 +7,7 @@
<parent>
<groupId>dev.vality.geck</groupId>
<artifactId>parent</artifactId>
<version>1.0.1</version>
<version>1.0.2</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@ -7,7 +7,7 @@
<parent>
<groupId>dev.vality.geck</groupId>
<artifactId>parent</artifactId>
<version>1.0.1</version>
<version>1.0.2</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@ -7,7 +7,7 @@
<parent>
<groupId>dev.vality.geck</groupId>
<artifactId>parent</artifactId>
<version>1.0.1</version>
<version>1.0.2</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@ -12,7 +12,7 @@
<groupId>dev.vality.geck</groupId>
<artifactId>parent</artifactId>
<version>1.0.1</version>
<version>1.0.2</version>
<packaging>pom</packaging>
<name>Geck</name>

View File

@ -7,7 +7,7 @@
<parent>
<groupId>dev.vality.geck</groupId>
<artifactId>parent</artifactId>
<version>1.0.1</version>
<version>1.0.2</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@ -12,10 +12,7 @@ import org.apache.thrift.meta_data.*;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.*;
public class TBaseProcessor implements StructProcessor<TBase> {
@ -84,6 +81,13 @@ public class TBaseProcessor implements StructProcessor<TBase> {
private void process(Object object, FieldValueMetaData fieldValueMetaData, StructHandler handler) throws IOException {
if (object == null) {
handler.nullValue();
} else if (object instanceof Optional<?> optional) {
if (optional.isPresent()) {
Object value = optional.get();
process(value, fieldValueMetaData, handler);
} else {
handler.nullValue();
}
} else {
ThriftType type = ThriftType.findByMetaData(fieldValueMetaData);