java.lang.Object
com.thecoderscorner.menu.remote.commands.CommandFactory

public class CommandFactory extends Object
These static helper methods are the preferred way to create command message that can be sent and received from a remote connection. Each protocol can convert sent and received messages into this form.
  • Constructor Details

    • CommandFactory

      public CommandFactory()
  • Method Details

    • newJoinCommand

      public static MenuJoinCommand newJoinCommand(String name)
      Create a new join command that has a random UUID
      Parameters:
      name - the name that the remote will show for the connection
      Returns:
      join command.
    • newJoinCommand

      public static MenuJoinCommand newJoinCommand(String name, UUID uuid)
      Create a new join command that has a fixed UUID that you provide.
      Parameters:
      name - the name that the remote will show for the connection
      uuid - the UUID that will the remote will see for this.
      Returns:
      join command
    • newHeartbeatCommand

      public static MenuHeartbeatCommand newHeartbeatCommand(int frequency, MenuHeartbeatCommand.HeartbeatMode mode)
      Create a new heartbeat message with the frequency specified
      Parameters:
      frequency - the frequency
      Returns:
      heartbeat command
    • newAcknowledgementCommand

      public static MenuAcknowledgementCommand newAcknowledgementCommand(CorrelationId correlationId, AckStatus status)
      create an acknowledgement message for a given correlation and status
      Parameters:
      correlationId - the correlation
      status - the status
      Returns:
      the message
    • newPairingCommand

      public static MenuPairingCommand newPairingCommand(String name, UUID uuid)
    • newDialogCommand

      public static MenuDialogCommand newDialogCommand(DialogMode mode, String header, String msg, MenuButtonType b1, MenuButtonType b2, CorrelationId correlationId)
    • newBootstrapCommand

      public static MenuBootstrapCommand newBootstrapCommand(MenuBootstrapCommand.BootType type)
      Create a new bootstrap message either to indicate the bootstrap start or end
      Parameters:
      type - one of the enum values allowed
      Returns:
      bootstrap message
    • newAnalogBootCommand

      public static MenuAnalogBootCommand newAnalogBootCommand(int parentId, AnalogMenuItem item, int currentVal)
      create a new analog bootstrap command.
      Parameters:
      parentId - the parent onto which the item will be placed.
      item - the item itself.
      currentVal - the current value
      Returns:
      a new analog boot command
    • newRuntimeListBootCommand

      public static MenuRuntimeListBootCommand newRuntimeListBootCommand(int parentId, RuntimeListMenuItem item, List<String> val)
      Create a new runtime list boot command
      Parameters:
      parentId - the parent onto which this will be placed
      item - the item itself.
      val - the current value
      Returns:
      a new runtime list boot command
    • newMenuSubBootCommand

      public static MenuSubBootCommand newMenuSubBootCommand(int parentId, SubMenuItem item)
      create a new submenu bootstrap command.
      Parameters:
      parentId - the parent onto which the item will be placed.
      item - the item itself.
      Returns:
      a new submenu boot command
    • newMenuEnumBootCommand

      public static MenuEnumBootCommand newMenuEnumBootCommand(int parentId, EnumMenuItem item, int currentVal)
      create a new enum bootstrap command.
      Parameters:
      parentId - the parent onto which the item will be placed.
      item - the item itself.
      currentVal - the current value
      Returns:
      a new enum boot command
    • newMenuBooleanBootCommand

      public static MenuBooleanBootCommand newMenuBooleanBootCommand(int parentId, BooleanMenuItem item, boolean currentVal)
      create a new boolean bootstrap command.
      Parameters:
      parentId - the parent onto which the item will be placed.
      item - the item itself.
      currentVal - the current value
      Returns:
      a new boolean boot command
    • newMenuFloatBootCommand

      public static MenuFloatBootCommand newMenuFloatBootCommand(int parentId, FloatMenuItem item, Float currentVal)
      create a new float bootstrap command.
      Parameters:
      parentId - the parent onto which the item will be placed.
      item - the item itself.
      currentVal - the current value
      Returns:
      a new float boot command
    • newMenuActionBootCommand

      public static MenuActionBootCommand newMenuActionBootCommand(int parentId, ActionMenuItem item)
      create a new action bootstrap command.
      Parameters:
      parentId - the parent onto which the item will be placed.
      item - the item itself.
      Returns:
      a new action boot command
    • newMenuTextBootCommand

      public static MenuTextBootCommand newMenuTextBootCommand(int parentId, EditableTextMenuItem item, String currentVal)
      create a new text bootstrap command.
      Parameters:
      parentId - the parent onto which the item will be placed.
      item - the item itself.
      currentVal - the current value
      Returns:
      a new text boot command
    • newLargeNumberBootItem

      public static MenuLargeNumBootCommand newLargeNumberBootItem(int parentId, EditableLargeNumberMenuItem item, BigDecimal currentVal)
      create a new large number bootstrap command.
      Parameters:
      parentId - the parent onto which the item will be placed.
      item - the item itself.
      currentVal - the current value
      Returns:
      a new number boot command
    • newDeltaChangeCommand

      public static MenuChangeCommand newDeltaChangeCommand(CorrelationId correlation, MenuItem item, int value)
      Creates a new delta change command given the menu item and the delta change in value.
      Parameters:
      correlation - a correlation ID that will be returned in the subsequent acknowledgement.
      item - the item for which to send
      value - the change in value as a delta of the current value
      Returns:
      a new change message
    • newAbsoluteMenuChangeCommand

      public static MenuChangeCommand newAbsoluteMenuChangeCommand(CorrelationId correlation, MenuItem item, Object value)
      Creates a new absolute change command given the menu item and the absolute change in value.
      Parameters:
      correlation - a correlation ID that will be returned in the subsequent acknowledgement.
      item - the item for which to send
      value - the new value
      Returns:
      a new change message
    • newDeltaChangeCommand

      public static MenuChangeCommand newDeltaChangeCommand(CorrelationId correlation, int itemId, int value)
      Creates a new delta change command given the menu item ID and the delta change in value.
      Parameters:
      correlation - a correlation ID that will be returned in the subsequent acknowledgement.
      itemId - the item ID for which to send
      value - the change in value as a delta of the current value
      Returns:
      a new change message
    • newAbsoluteMenuChangeCommand

      public static MenuChangeCommand newAbsoluteMenuChangeCommand(CorrelationId correlation, int itemId, Object value)
      Creates a new absolute change command given the menu item ID and the absolute change in value.
      Parameters:
      correlation - a correlation ID that will be returned in the subsequent acknowledgement.
      itemId - the item ID for which to send
      value - the new value
      Returns:
      a new change message
    • newAbsoluteListChangeCommand

      public static MenuChangeCommand newAbsoluteListChangeCommand(CorrelationId correlation, int itemId, List<String> values)
      Creates a new absolute change command given the menu item ID and the absolute change in value.
      Parameters:
      correlation - a correlation ID that will be returned in the subsequent acknowledgement.
      itemId - the item ID for which to send
      values - the new value
      Returns:
      a new change message