def build_type(field):
  """
  Function to pack a type into the binary payload.
  """
  if field.type_id == 'string':
    if 'size' in field.options:
      return "builder.putString(%s, %d)" % (field.identifier, field.options['size'].value)
    else:
      return "builder.putString(%s)" % field.identifier
  elif field.type_id in JAVA_TYPE_MAP:
    # Primitive java types have extractor methods in SBPMessage.Builder
    return "builder.put%s(%s)" % (field.type_id.capitalize(), field.identifier)
  if field.type_id == 'array':
    # Call function to build array
    t = field.options['fill'].value
    if t in JAVA_TYPE_MAP:
      if 'size' in field.options:
        return "builder.putArrayof%s(%s, %d)" % (t.capitalize(),
                                                 field.identifier,
                                                 field.options['size'].value)
      else:
        return "builder.putArrayof%s(%s)" % (t.capitalize(), field.identifier)
    else:
      if 'size' in field.options:
        return "builder.putArray(%s, %d)" % (field.identifier, field.options['size'].value)
      else:
        return "builder.putArray(%s)" % field.identifier
  else:
    return "%s.build(builder)" % field.identifier
Function to pack a type into the binary payload.