protected void writeLabels(final FudgeSerializer serializer, final MutableFudgeMsg message, final Object[] labels, final String valueKey, final String typeKey) {
final MutableFudgeMsg valueMsg = serializer.newMessage();
final MutableFudgeMsg typeMsg = serializer.newMessage();
boolean needsTypeInfo = false;
for (Object label : labels) {
final FudgeFieldType type = serializer.getFudgeContext().getTypeDictionary().getByJavaType(label.getClass());
if (type == null) {
serializer.addToMessage(valueMsg, null, null, label);
valueMsg.add(null, null, FudgeWireType.SUB_MESSAGE, serializer.objectToFudgeMsg(label));
typeMsg.add(null, null, label.getClass().getName());
needsTypeInfo = true;
} else {
valueMsg.add(null, null, type, label);
if (type instanceof SecondaryFieldType<?, ?>) {
typeMsg.add(null, null, type.getJavaType().getName());
needsTypeInfo = true;
} else {
typeMsg.add(null, null, type.getTypeId());
}
}
}
if (!needsTypeInfo) {
// Message contains only primitive types; only put the type info in if there have been type reductions