@Test public void testValidationOfSingleAndMultipleArguments() { try { actions.perform(EmptyValidArguments.class); actions.perform(TwoArgumentsAction.class, "", true); actions.perform(MultipleValidArguments.class, "", true); actions.perform(MultipleValidArguments.class); actions.perform(MultipleValidArguments.class, 50); } catch (ArgumentsValidationException e) { fail("Error testing validation of the list of arguments " + e.getMessage()); } }
public boolean perform(Class actionClass, Object... args) throws ArgumentsValidationException { Action action = getAction(actionClass); if (action != null && action.isEnabled()) { if (action.validate(args)) { Gdx.app.debug("Controller", ClassReflection.getSimpleName(actionClass) + prettyPrintArgs(args)); logAction(action.getClass(), args); if (action instanceof ModelAction) { modelActions.perform((ModelAction) action, args); } else if (action instanceof EditorAction) { editorActions.perform((EditorAction) action, args); } if (action.isTrackable()) { controller.getTracker().actionPerformed(actionClass, true); } return true; } else { if (action.isTrackable()) { controller.getTracker().actionPerformed(actionClass, false); } throw new ArgumentsValidationException(actionClass, args); } } else { Gdx.app.debug("Actions", "Action with class " + actionClass + (action == null ? " does not exist." : " is disabled.")); } return false; }
Actions { public boolean perform(Class actionClass, Object... args) throws ArgumentsValidationException { Action action = getAction(actionClass); if (action != null && action.isEnabled()) { if (action.validate(args)) { Gdx.app.debug("Controller", ClassReflection.getSimpleName(actionClass) + prettyPrintArgs(args)); logAction(action.getClass(), args); if (action instanceof ModelAction) { modelActions.perform((ModelAction) action, args); } else if (action instanceof EditorAction) { editorActions.perform((EditorAction) action, args); } if (action.isTrackable()) { controller.getTracker().actionPerformed(actionClass, true); } return true; } else { if (action.isTrackable()) { controller.getTracker().actionPerformed(actionClass, false); } throw new ArgumentsValidationException(actionClass, args); } } else { Gdx.app.debug("Actions", "Action with class " + actionClass + (action == null ? " does not exist." : " is disabled.")); } return false; } }
Actions { public boolean perform(Class actionClass, Object... args) throws ArgumentsValidationException { Action action = getAction(actionClass); if (action != null && action.isEnabled()) { if (action.validate(args)) { Gdx.app.debug("Controller", ClassReflection.getSimpleName(actionClass) + prettyPrintArgs(args)); logAction(action.getClass(), args); if (action instanceof ModelAction) { modelActions.perform((ModelAction) action, args); } else if (action instanceof EditorAction) { editorActions.perform((EditorAction) action, args); } if (action.isTrackable()) { controller.getTracker().actionPerformed(actionClass, true); } return true; } else { if (action.isTrackable()) { controller.getTracker().actionPerformed(actionClass, false); } throw new ArgumentsValidationException(actionClass, args); } } else { Gdx.app.debug("Actions", "Action with class " + actionClass + (action == null ? " does not exist." : " is disabled.")); } return false; } Actions(Controller controller); }
Actions { public boolean perform(Class actionClass, Object... args) throws ArgumentsValidationException { Action action = getAction(actionClass); if (action != null && action.isEnabled()) { if (action.validate(args)) { Gdx.app.debug("Controller", ClassReflection.getSimpleName(actionClass) + prettyPrintArgs(args)); logAction(action.getClass(), args); if (action instanceof ModelAction) { modelActions.perform((ModelAction) action, args); } else if (action instanceof EditorAction) { editorActions.perform((EditorAction) action, args); } if (action.isTrackable()) { controller.getTracker().actionPerformed(actionClass, true); } return true; } else { if (action.isTrackable()) { controller.getTracker().actionPerformed(actionClass, false); } throw new ArgumentsValidationException(actionClass, args); } } else { Gdx.app.debug("Actions", "Action with class " + actionClass + (action == null ? " does not exist." : " is disabled.")); } return false; } Actions(Controller controller); T getAction(Class<T> actionClass); boolean perform(Class actionClass, Object... args); void addActionListener(Class actionClass, ActionListener listener); boolean isEnabled(Class actionClass); Array<TimestampedEditorAction> getLoggedActions(int nActions); }
Actions { public boolean perform(Class actionClass, Object... args) throws ArgumentsValidationException { Action action = getAction(actionClass); if (action != null && action.isEnabled()) { if (action.validate(args)) { Gdx.app.debug("Controller", ClassReflection.getSimpleName(actionClass) + prettyPrintArgs(args)); logAction(action.getClass(), args); if (action instanceof ModelAction) { modelActions.perform((ModelAction) action, args); } else if (action instanceof EditorAction) { editorActions.perform((EditorAction) action, args); } if (action.isTrackable()) { controller.getTracker().actionPerformed(actionClass, true); } return true; } else { if (action.isTrackable()) { controller.getTracker().actionPerformed(actionClass, false); } throw new ArgumentsValidationException(actionClass, args); } } else { Gdx.app.debug("Actions", "Action with class " + actionClass + (action == null ? " does not exist." : " is disabled.")); } return false; } Actions(Controller controller); T getAction(Class<T> actionClass); boolean perform(Class actionClass, Object... args); void addActionListener(Class actionClass, ActionListener listener); boolean isEnabled(Class actionClass); Array<TimestampedEditorAction> getLoggedActions(int nActions);  }