Source:
<code>private List<Map<String, Object>> parseDisks(XmlDocument document, List<VmDevice> devices) { List<VmDevice> dbDevices = filterDevices(devices, VmDeviceGeneralType.DISK); MemoizingSupplier<Map<Guid, String>> diskToLunSupplier = new MemoizingSupplier<>( () -> diskLunMapDao.getAll().stream().collect(Collectors.toMap( DiskLunMap::getDiskId, DiskLunMap::getLunId))); List<Map<String, Object>> result = new ArrayList<>(); for (XmlNode node : selectNodes(document, VmDeviceGeneralType.DISK)) { Map<String, Object> dev = new HashMap<>(); dev.put(VdsProperties.Type, VmDeviceGeneralType.DISK.getValue()); String diskType = parseAttribute(node, DEVICE); dev.put(VdsProperties.Device, diskType); dev.put(VdsProperties.Address, parseAddress(node)); dev.put(VdsProperties.Alias, parseAlias(node)); String path = parseDiskPath(node); VmDevice dbDev = dbDevices.stream() .filter(d -> { <START> switch(diskType) <END> { case "cdrom": String devicePath = (String) d.getSpecParams().get("path"); return devicePath == null || path.contains(devicePath); case "floppy": return true; default: Guid diskId = d.getId().getDeviceId(); return path.contains(diskId.toString()) || isPathContainsLunIdOfDisk(path, diskId, diskToLunSupplier); } }) .findFirst() .orElse(null); if (dbDev == null) { log.warn("unmanaged disk with path '{}' is ignored", path); continue; } dbDevices.remove(dbDev); dev.put(VdsProperties.DeviceId, dbDev.getId().getDeviceId().toString()); dev.put(VdsProperties.SpecParams, dbDev.getSpecParams()); result.add(dev); } return result; }</code><technical_language>about: if (!diskType.equals(d.getDevice())) { return false; } in "cdrom" and: return diskType.equals(d.getDevice()); in "floppy"</technical_language>

Target:
private List<Map<String, Object>> parseDisks(XmlDocument document, List<VmDevice> devices) { List<VmDevice> dbDevices = filterDevices(devices, VmDeviceGeneralType.DISK); MemoizingSupplier<Map<Guid, String>> diskToLunSupplier = new MemoizingSupplier<>( () -> diskLunMapDao.getAll().stream().collect(Collectors.toMap( DiskLunMap::getDiskId, DiskLunMap::getLunId))); List<Map<String, Object>> result = new ArrayList<>(); for (XmlNode node : selectNodes(document, VmDeviceGeneralType.DISK)) { Map<String, Object> dev = new HashMap<>(); dev.put(VdsProperties.Type, VmDeviceGeneralType.DISK.getValue()); String diskType = parseAttribute(node, DEVICE); dev.put(VdsProperties.Device, diskType); dev.put(VdsProperties.Address, parseAddress(node)); dev.put(VdsProperties.Alias, parseAlias(node)); String path = parseDiskPath(node); VmDevice dbDev = dbDevices.stream() .filter(d -> { switch(diskType) { case "cdrom": if (!diskType.equals(d.getDevice())) { return false; } String devicePath = (String) d.getSpecParams().get("path"); return devicePath == null || path.contains(devicePath); case "floppy": return diskType.equals(d.getDevice()); default: Guid diskId = d.getId().getDeviceId(); return path.contains(diskId.toString()) || isPathContainsLunIdOfDisk(path, diskId, diskToLunSupplier); } }) .findFirst() .orElse(null); if (dbDev == null) { log.warn("unmanaged disk with path '{}' is ignored", path); continue; } dbDevices.remove(dbDev); dev.put(VdsProperties.DeviceId, dbDev.getId().getDeviceId().toString()); dev.put(VdsProperties.SpecParams, dbDev.getSpecParams()); result.add(dev); } return result; }