public void write(TProtocol oprot) throws TException {
    validate();

    oprot.writeStructBegin(STRUCT_DESC);
    oprot.writeFieldBegin(USER_ID_FIELD_DESC);
    oprot.writeI32(this.userId);
    oprot.writeFieldEnd();
    if (this.shardId != null) {
      oprot.writeFieldBegin(SHARD_ID_FIELD_DESC);
      oprot.writeString(this.shardId);
      oprot.writeFieldEnd();
    }
    if (this.privilege != null) {
      if (isSetPrivilege()) {
        oprot.writeFieldBegin(PRIVILEGE_FIELD_DESC);
        oprot.writeI32(this.privilege.getValue());
        oprot.writeFieldEnd();
      }
    }
    if (this.username != null) {
      if (isSetUsername()) {
        oprot.writeFieldBegin(USERNAME_FIELD_DESC);
        oprot.writeString(this.username);
        oprot.writeFieldEnd();
      }
    }
    if (this.noteStoreUrl != null) {
      if (isSetNoteStoreUrl()) {
        oprot.writeFieldBegin(NOTE_STORE_URL_FIELD_DESC);
        oprot.writeString(this.noteStoreUrl);
        oprot.writeFieldEnd();
      }
    }
    if (this.webApiUrlPrefix != null) {
      if (isSetWebApiUrlPrefix()) {
        oprot.writeFieldBegin(WEB_API_URL_PREFIX_FIELD_DESC);
        oprot.writeString(this.webApiUrlPrefix);
        oprot.writeFieldEnd();
      }
    }
    oprot.writeFieldStop();
    oprot.writeStructEnd();
  }