// same code as above! @Override public void checkAllHardwareStopped() throws HardwareException { Module mainModule = (Module) lookup.getComponentByName("main"); if (mainModule == null) { throw new IllegalArgumentException("no component named main!"); // TODO log ? or error } final MutableReference<HardwareException> excList = new MutableReference<>(); mainModule.proceduralWalk( configurable -> { if (configurable instanceof HardwareController) { try { ((HardwareController) configurable).checkStopped(); } catch (HardwareException e) { excList.reference = new HardwareException( configurable.toString() + "not stopped ", e, excList.reference); } } }, null); /* */ if (excList.reference != null) { throw excList.reference; } }
/** * invoke a <TT>checkHardware</TT> on all <TT>HardwareController</TT> (except when return diag * modifies the path of invocation) * * @throws HardwareException a list of HardwareException */ @Override public void checkHardware() throws HardwareException { Module mainModule = (Module) lookup.getComponentByName("main"); if (mainModule == null) { throw new IllegalArgumentException("no component named main!"); // TODO log ? or error } final MutableReference<HardwareException> excList = new MutableReference<>(); mainModule.treeWalk( configurable -> { if (configurable instanceof HardwareController) { try { return ((HardwareController) configurable).checkHardware(); } catch (HardwareException e) { excList.reference = new HardwareException( configurable.toString() + " fails check", e, excList.reference); // todo: not correct: what if not fatal and we still want to return Handler-children if (e.isFatal()) { return TreeWalkerDiag.STOP; } } } return TreeWalkerDiag.GO; }, null); /* */ if (excList.reference != null) { throw excList.reference; } }