build static method

ActionRecipe build(
  1. ActionRecipe recipe
)

Processes a final ActionRecipe based on a raw one received from the server.

Implementation

static ActionRecipe build(ActionRecipe recipe) {
  //Normalize It, \n Get removed in trim so
  final cmdText = recipe.receivedText
      .replaceAll("\n", AugnitoCommands.nextLineText)
      .replaceAll(" ", "")
      .toLowerCase()
      .trim()
      .replaceAll(AugnitoCommands.nextLineText, "\n");
  recipe.name = cmdText;
  recipe.receivedTextWithoutSpace = cmdText;

  if (recipe.action.isNotEmpty) {
    recipe.action = recipe.action
        .replaceAll("\n", AugnitoCommands.nextLineText)
        .replaceAll(" ", "")
        .toLowerCase()
        .trim()
        .replaceAll(AugnitoCommands.nextLineText, "\n");
  }

  // If IsCommand is true at this point, then the action is a static command
  if (recipe.isStaticCommand) {
    // Set static command
    AugnitoStaticCommandProcessor.formatStaticCommand(recipe);
    return recipe;
  }

  // Trim space before and after \n
  CommandUtils.triNewLine(recipe);

  // Dynamic command
  AugnitoDynamicCommandProcessor.fillDynamicCommand(recipe, cmdText);

  return recipe;
}