Object value) throws TException {
if (value == null) {
return;
}
Field innerField = null;
switch (field.getType()) {
case TType.LIST:
innerField = field.getListElemField(); break;
case TType.SET:
innerField = field.getSetElemField(); break;
case TType.MAP:
innerField = field.getMapKeyField(); break;
default:
writeSingleFieldNoTag(proto, field, value);
return;
}
// a map or a collection:
if (field.getType() == TType.MAP) {
Field valueField = field.getMapValueField();
Map<?, ?> map = (Map<?, ?>)value;
proto.writeByte(innerField.getType());
proto.writeByte(valueField.getType());
proto.writeI32(map.size());
for(Entry<?, ?> entry : map.entrySet()) {
writeSingleFieldNoTag(proto, innerField, entry.getKey());
writeSingleFieldNoTag(proto, valueField, entry.getValue());