protected final synchronized TestAction register(Class<? extends WaspAction> waspActionClass,
TestAction action) throws RegistrationException
{
// sanity checks
if (AllActions.class.isAssignableFrom(waspActionClass))
throw new RegistrationException("Can not register 'all' actions");
if (power > 30)
throw new RegistrationException("Can not register more then 32 different actions.");
int assignedPowerOf2 = nextPowerOf2();
if (assignedPowerOf2 > maxAssingableAction)
throw new RegistrationException(
"Unable to register an action with a base value greater then " +
maxAssingableAction);
if (assignedPowerOf2 < 0)
throw new RegistrationException(assignedPowerOf2 + " is not a positive value");
// includes any implied actions
Integer powerOf2 = Integer.valueOf(action.actions());
if (!implies(powerOf2.intValue(), assignedPowerOf2))
throw new RegistrationException("Unable to register action '" + action.getName() +
"' with value " + powerOf2 + " expected " + assignedPowerOf2 + " or more.");
// end of checks
stringValues.put(powerOf2, action.getName());
registeredIntActions.put(Integer.valueOf(power), action);