/**
 * Autogenerated by Thrift
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 *  @generated
 */


import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import com.facebook.thrift.lite.*;
import com.facebook.thrift.lite.protocol.*;


public class ModuleLogger {

  public final Module.EventType mEventType;

  private final Map<ThriftProperty<?>, Object> mMap = new HashMap<ThriftProperty<?>, Object>();

  public ModuleLogger(Module.EventType type) {
    mEventType = type;
  }

  public <T> ModuleLogger addProperty(ThriftProperty<T> property, T value) {
    mMap.put(property, value);
    return this;
  }

  public static <T> void writeFieldBegin(TBinaryProtocol oprot, ThriftProperty<T> field) throws IOException {
    TField tField = new TField(field.key, field.type, field.id);
    oprot.writeFieldBegin(tField);
  }

  public void write(TBinaryProtocol oprot) throws IOException {
    switch (mEventType) {
      case MyStruct: {
        oprot.writeStructBegin(new TStruct("MyStruct"));
        if (mMap.containsKey(Module.MyStruct_MyIncludedField) && mMap.get(Module.MyStruct_MyIncludedField) != null) {
          writeFieldBegin(oprot, Module.MyStruct_MyIncludedField);
          ((one.two.three.IncludesLogger) mMap.get(Module.MyStruct_MyIncludedField)).write(oprot);
          oprot.writeFieldEnd();
        }
      
        oprot.writeFieldStop();
        oprot.writeStructEnd();
        break;
      }
      
      
    }
  }
}
