/**
  * Adds an object to the specified message if non-null.
  *
  * @param <T> the declared type
  * @param msg the msg to populate, not null
  * @param fieldName the field name, may be null
  * @param objectMsg the object converted to a message, null ignored
  * @param value the value, null ignored
  * @param declaredType the declared Java type of the field, not null
  */
 protected static <T> void addToMessage(
     final MutableFudgeMsg msg,
     final String fieldName,
     final FudgeMsg objectMsg,
     final T value,
     final Class<T> declaredType) {
   if (objectMsg != null) {
     FudgeSerializer.addClassHeader((MutableFudgeMsg) objectMsg, value.getClass(), declaredType);
     msg.add(fieldName, null, objectMsg);
   }
 }
 @Override
 public MutableFudgeMsg buildMessage(
     final FudgeSerializer serializer,
     final BloombergEquityFutureOptionVolatilitySurfaceInstrumentProvider object) {
   final MutableFudgeMsg message = serializer.newMessage();
   FudgeSerializer.addClassHeader(
       message, BloombergEquityFutureOptionVolatilitySurfaceInstrumentProvider.class);
   message.add(PREFIX_FIELD_NAME, object.getFutureOptionPrefix());
   message.add(POSTFIX_FIELD_NAME, object.getPostfix());
   message.add(DATA_FIELD_NAME, object.getDataFieldName());
   message.add(CALL_FIELD_NAME, object.useCallAboveStrike());
   message.add(EXCHANGE_ID_FIELD_NAME, object.getExchangeIdName());
   message.add(TICKER_SCHEME_NAME, object.getSchemeName());
   return message;
 }
 public void toFudgeMsg(
     final org.fudgemsg.mapping.FudgeSerializer serializer,
     final org.fudgemsg.MutableFudgeMsg msg) {
   if (_responses != null) {
     for (com.opengamma.livedata.msg.EntitlementResponse fudge1 : _responses) {
       final org.fudgemsg.MutableFudgeMsg fudge2 =
           org.fudgemsg.mapping.FudgeSerializer.addClassHeader(
               serializer.newMessage(),
               fudge1.getClass(),
               com.opengamma.livedata.msg.EntitlementResponse.class);
       fudge1.toFudgeMsg(serializer, fudge2);
       msg.add(RESPONSES_KEY, null, fudge2);
     }
   }
 }
 /**
  * Adds an object to the specified message if non-null. This handles object hierarchies.
  *
  * @param <T> the declared type
  * @param serializer the serializer, not null
  * @param msg the msg to populate, not null
  * @param fieldName the field name, may be null
  * @param value the value, null ignored
  * @param declaredType the declared Java type of the field, not null
  */
 protected static <T> void addToMessage(
     final FudgeSerializer serializer,
     final MutableFudgeMsg msg,
     final String fieldName,
     final T value,
     final Class<T> declaredType) {
   if (value != null) {
     MutableFudgeMsg subMsg = serializer.newMessage();
     FudgeSerializer.addClassHeader(subMsg, value.getClass(), declaredType);
     FudgeMsg builtMsg = serializer.objectToFudgeMsg(value);
     for (FudgeField field : builtMsg) {
       subMsg.add(field);
     }
     msg.add(fieldName, null, subMsg);
   }
 }