BridgeModel implements IModel<Boolean> { @Override public void setObject(Boolean object) { if (object) { innerModel.setObject(outerModel.getObject()); } else { innerModel.setObject(falseValue); } bridgeStateModel.setObject(object); } BridgeModel(IModel<T> innerModel, IModel<T> outerModel, IModel<Boolean> bridgeStateModel, T falseValue); @Override Boolean getObject(); @Override void setObject(Boolean object); @Override void detach();  }
@Test public void testSetObject() { IModel<String> inner = Model.of("inner value"); IModel<String> outer = Model.of("outer value"); IModel<Boolean> state = Model.of(false); String falseValue = "bridge closed"; BridgeModel instance = new BridgeModel(inner, outer, state, falseValue); assertEquals("inner value", inner.getObject()); assertFalse(state.getObject()); instance.setObject(true); assertTrue(state.getObject()); assertEquals("outer value", inner.getObject()); instance.setObject(false); assertFalse(state.getObject()); assertEquals("bridge closed", inner.getObject()); }