class AggregatingToolScanManager implements ToolScanManager {

    public ToolVersionScanResult scanTool(Tool tool, String tag, Boolean rescan)
            throws ToolScanExternalServiceException {
        DockerRegistry registry = dockerRegistryManager.load(tool.getRegistryId());
        Optional<ToolVersionScanResult> actualScan = rescan ? Optional.empty() : getActualScan(tool, tag, registry);
        return actualScan.isPresent() ? actualScan.get() : doScan(tool, tag, registry);
    }

}