BridgeOuterModel implements IModel<T> { @Override public void setObject(T object) { value = object; if (bridgeStateModel.getObject()) { innerModel.setObject(object); } } BridgeOuterModel(IModel<T> innerModel, IModel<Boolean> bridgeStateModel, T value); @Override T getObject(); @Override void setObject(T object); @Override void detach();  }
@Test public void testSetObject() { IModel<String> inner = Model.of("inner value"); IModel<Boolean> state = Model.of(false); BridgeOuterModel instance = new BridgeOuterModel(inner, state, "initial outer"); instance.setObject("new outer"); assertEquals("inner value", inner.getObject()); state.setObject(true); assertEquals("inner value", inner.getObject()); instance.setObject("new outer/inner"); assertEquals("new outer/inner", inner.getObject()); }