Using Command Based Java, is it safe and will it work to remap a Button action at run-time?
Example, in the OI class:
Code:
public Button stick2_B = new JoystickButton(stick2, RobotMap.XBOX_B);
stick2_B.whenPressed(new Command1());
Later, in the execute method of a command I want to do:
Code:
if(SOME_CONDITION)
{
oi.stick2_B.whenPressed(new Command2());
}
I've already confirmed it will compile so the question is really if it will behave correctly at run-time. Specifically do I need to do anything to de-register stick2_B as a trigger for Command1 or any other sort up cleanup first? I would just test it but I don't have access to a robot until later this week for obvious reasons. Please don't tell me it should work or you think it will work

Only if you know from knowledge of the WPILib or experience. Thanks!