/**
   * Decodes this TransportConfiguration from a buffer.
   *
   * <p>Note this is only used internally by ActiveMQ
   *
   * @param buffer the buffer to decode from
   */
  public void decode(final ActiveMQBuffer buffer) {
    name = buffer.readString();
    factoryClassName = buffer.readString();

    int num = buffer.readInt();

    if (params == null) {
      if (num > 0) {
        params = new HashMap<>();
      }
    } else {
      params.clear();
    }

    for (int i = 0; i < num; i++) {
      String key = buffer.readString();

      byte type = buffer.readByte();

      Object val;

      switch (type) {
        case TYPE_BOOLEAN:
          {
            val = buffer.readBoolean();

            break;
          }
        case TYPE_INT:
          {
            val = buffer.readInt();

            break;
          }
        case TYPE_LONG:
          {
            val = buffer.readLong();

            break;
          }
        case TYPE_STRING:
          {
            val = buffer.readString();

            break;
          }
        default:
          {
            throw ActiveMQClientMessageBundle.BUNDLE.invalidType(type);
          }
      }

      params.put(key, val);
    }
  }