Class CommandFactory
- java.lang.Object
-
- com.thecoderscorner.menu.remote.commands.CommandFactory
-
public class CommandFactory extends java.lang.ObjectThese 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 Summary
Constructors Constructor Description CommandFactory()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static MenuChangeCommandnewAbsoluteListChangeCommand(CorrelationId correlation, int itemId, java.util.List<java.lang.String> values)Creates a new absolute change command given the menu item ID and the absolute change in value.static MenuChangeCommandnewAbsoluteMenuChangeCommand(CorrelationId correlation, int itemId, java.lang.Object value)Creates a new absolute change command given the menu item ID and the absolute change in value.static MenuChangeCommandnewAbsoluteMenuChangeCommand(CorrelationId correlation, MenuItem item, java.lang.Object value)Creates a new absolute change command given the menu item and the absolute change in value.static MenuAcknowledgementCommandnewAcknowledgementCommand(CorrelationId correlationId, AckStatus status)create an acknowledgement message for a given correlation and statusstatic MenuAnalogBootCommandnewAnalogBootCommand(int parentId, AnalogMenuItem item, int currentVal)create a new analog bootstrap command.static MenuBootstrapCommandnewBootstrapCommand(MenuBootstrapCommand.BootType type)Create a new bootstrap message either to indicate the bootstrap start or endstatic MenuChangeCommandnewDeltaChangeCommand(CorrelationId correlation, int itemId, int value)Creates a new delta change command given the menu item ID and the delta change in value.static MenuChangeCommandnewDeltaChangeCommand(CorrelationId correlation, MenuItem item, int value)Creates a new delta change command given the menu item and the delta change in value.static MenuDialogCommandnewDialogCommand(DialogMode mode, java.lang.String header, java.lang.String msg, MenuButtonType b1, MenuButtonType b2, CorrelationId correlationId)static MenuHeartbeatCommandnewHeartbeatCommand(int frequency)Create a new heartbeat message with the frequency specifiedstatic MenuJoinCommandnewJoinCommand(java.lang.String name)Create a new join command that has a random UUIDstatic MenuJoinCommandnewJoinCommand(java.lang.String name, java.util.UUID uuid)Create a new join command that has a fixed UUID that you provide.static MenuActionBootCommandnewMenuActionBootCommand(int parentId, ActionMenuItem item)create a new action bootstrap command.static MenuBooleanBootCommandnewMenuBooleanBootCommand(int parentId, BooleanMenuItem item, boolean currentVal)create a new boolean bootstrap command.static MenuEnumBootCommandnewMenuEnumBootCommand(int parentId, EnumMenuItem item, int currentVal)create a new enum bootstrap command.static MenuFloatBootCommandnewMenuFloatBootCommand(int parentId, FloatMenuItem item, java.lang.Float currentVal)create a new float bootstrap command.static MenuSubBootCommandnewMenuSubBootCommand(int parentId, SubMenuItem item)create a new submenu bootstrap command.static MenuTextBootCommandnewMenuTextBootCommand(int parentId, EditableTextMenuItem item, java.lang.String currentVal)create a new text bootstrap command.static MenuPairingCommandnewPairingCommand(java.lang.String name, java.util.UUID uuid)static MenuRuntimeListBootCommandnewRuntimeListBootCommand(int parentId, RuntimeListMenuItem item, java.util.List<java.lang.String> val)Create a new runtime list boot command
-
-
-
Method Detail
-
newJoinCommand
public static MenuJoinCommand newJoinCommand(java.lang.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(java.lang.String name, java.util.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 connectionuuid- the UUID that will the remote will see for this.- Returns:
- join command
-
newHeartbeatCommand
public static MenuHeartbeatCommand newHeartbeatCommand(int frequency)
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 correlationstatus- the status- Returns:
- the message
-
newPairingCommand
public static MenuPairingCommand newPairingCommand(java.lang.String name, java.util.UUID uuid)
-
newDialogCommand
public static MenuDialogCommand newDialogCommand(DialogMode mode, java.lang.String header, java.lang.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, java.util.List<java.lang.String> val)
Create a new runtime list boot command- Parameters:
parentId- the parent onto which this will be placeditem- 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, java.lang.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, java.lang.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
-
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 sendvalue- 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, java.lang.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 sendvalue- 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 sendvalue- 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, java.lang.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 sendvalue- the new value- Returns:
- a new change message
-
newAbsoluteListChangeCommand
public static MenuChangeCommand newAbsoluteListChangeCommand(CorrelationId correlation, int itemId, java.util.List<java.lang.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 sendvalues- the new value- Returns:
- a new change message
-
-