ParameterService { public synchronized void setParam(Parameter param, Object value) { 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; } } ParameterService(RoboStrokeEventBus bus); synchronized void addListener(ParameterListenerRegistration ...value); synchronized void removeListener(ParameterListenerRegistration ...value); void addListeners(ParameterListenerOwner listenersOwner); void removeListeners(ParameterListenerOwner listenersOwner); synchronized void removeListener(String paramId, ParameterChangeListener listener); synchronized void addListener(String paramId, ParameterChangeListener listener); synchronized void registerParam(Parameter ... param); synchronized void setParam(Parameter param, Object value); synchronized void setParam(String id, Object value); @SuppressWarnings("unchecked") T getValue(String id); Map<String, Parameter> getParamMap(); synchronized Parameter getParam(String id);  }
@Test public void testSetParam() { assertEquals(.5f, (Float)f.getDefaultValue(), 0); ps.setParam("float", "0.7"); assertEquals(.7f, (Float)f.getValue(), 0); ps.setParam(f, 0.8f); assertEquals(.8f, (Float)f.getValue(), 0); }
@Test public void testSetParamViaListener() { ps.setParam("int", "7"); assertEquals(7, intVal); ps.setParam("int", "8"); assertEquals(8, intVal); }