class ParameterService {

	public synchronized void setParam(Parameter param, Object value) {
		
		// check either param is registered
		if (getParam(param.getId()) != param) {
			throw new IllegalArgumentException(String.format("parameter provided with id %s is not the same as the registered one"));
		}
		
		try {
			if (recursionOn) {
				throw new IllegalStateException("recursion detected - parameter listeners are not allowed to modify parameters from within same thread");
			}
			
			recursionOn = true;
			
			if (param.setParameterValue(value)) {
				onParamChanged(param);
			}
		} finally {
			recursionOn = false;
		}
	}

}

class ParameterServiceTest {

	private static final ParameterInfo BOOLEAN_PARAM;
	private static final ParameterInfo INTEGER_PARAM;
	private static final ParameterInfo FLOAT_PARAM;
	 Parameter f;
	 Parameter i;
	 Parameter b;
	private ParameterService ps;
	private final RoboStrokeEventBus bus;
	private final ParameterListenerRegistration[] listenerRegistration;
	private int intVal;

	@Test
	public void testSetParamViaListener() {

		ps.setParam("int", "7");
		assertEquals(7, intVal);
		ps.setParam("int", "8");
		assertEquals(8, intVal);
	}

}