getBuilder static method

MonitorVerbBuilder getBuilder(
  1. String command
)

Create a MonitorVerbBuilder from an atProtocol command string

Implementation

static MonitorVerbBuilder getBuilder(String command) {
  if (command != command.trim()) {
    throw IllegalArgumentException(
        'Commands may not have leading or trailing whitespace');
  }
  HashMap<String, String?>? verbParams =
      (VerbUtil.getVerbParam(VerbSyntax.monitor, command));
  if (verbParams == null) {
    throw InvalidSyntaxException('Command does not match the monitor syntax');
  }

  var builder = MonitorVerbBuilder();
  builder.strict = verbParams[AtConstants.monitorStrictMode] ==
      AtConstants.monitorStrictMode;
  builder.selfNotificationsEnabled =
      verbParams[AtConstants.monitorSelfNotifications] ==
          AtConstants.monitorSelfNotifications;
  builder.multiplexed = verbParams[AtConstants.monitorMultiplexedMode] ==
      AtConstants.monitorMultiplexedMode;
  builder.regex = verbParams[AtConstants.monitorRegex];
  builder.lastNotificationTime =
      verbParams[AtConstants.epochMilliseconds] == null
          ? null
          : int.parse(verbParams[AtConstants.epochMilliseconds]!);

  return builder;
}