com.adgear.anoa.write.ThriftWriter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of anoa-core Show documentation
Show all versions of anoa-core Show documentation
Core classes for Anoa library, which aims to be a safe, convenient and fast record
de/serialization wrapper for the Avro, Thrift and Jackson libraries, using the functional idioms
of Java 8.
The anoa-core module tries to keep upstream dependencies to a minimum.
package com.adgear.anoa.write;
import com.adgear.anoa.AnoaReflectionUtils;
import com.fasterxml.jackson.core.JsonGenerator;
import org.apache.thrift.TBase;
import org.apache.thrift.TFieldIdEnum;
import org.apache.thrift.meta_data.FieldValueMetaData;
import org.apache.thrift.meta_data.ListMetaData;
import org.apache.thrift.meta_data.MapMetaData;
import org.apache.thrift.meta_data.SetMetaData;
import org.apache.thrift.meta_data.StructMetaData;
import org.apache.thrift.protocol.TType;
import java.io.IOException;
import java.util.LinkedHashMap;
import java.util.Map;
class ThriftWriter> extends AbstractWriter {
final private LinkedHashMap> fieldMap;
@SuppressWarnings("unchecked")
ThriftWriter(Class thriftClass) {
fieldMap = new LinkedHashMap<>();
AnoaReflectionUtils.getThriftMetaDataMap(thriftClass).entrySet().stream()
.forEach(e -> fieldMap.put(
(F) e.getKey(),
(AbstractWriter