public Map<String, ? extends Device> apply(Map<String, String> from) { Builder<Device> devices = ImmutableSet.builder(); addIDEDevices(from, devices); addSCSIDevices(from, devices); addBlockDevices(from, devices); return Maps.uniqueIndex(devices.build(), deviceToId); }
protected void addIDEDevices(Map<String, String> from, Builder<Device> devices) { IDE: for (int bus : new int[] { 0, 1 }) for (int unit : new int[] { 0, 1 }) { String key = String.format("ide:%d:%d", bus, unit); if (!from.containsKey(key)) break IDE; devices.add(populateBuilder(new IDEDevice.Builder(bus, unit), key, from).build()); } }
protected void addBlockDevices(Map<String, String> from, Builder<Device> devices) { BLOCK: for (int index : new int[] { 0, 1, 2, 3, 4, 5, 6, 7 }) { String key = String.format("block:0:%d", index); if (!from.containsKey(key)) break BLOCK; devices.add(populateBuilder(new BlockDevice.Builder(index), key, from).build()); } }
public Map<String, ? extends Device> apply(Map<String, String> from) { Builder<Device> devices = ImmutableSet.builder(); addIDEDevices(from, devices); addSCSIDevices(from, devices); addBlockDevices(from, devices); return Maps.uniqueIndex(devices.build(), deviceToId); }
protected void addSCSIDevices(Map<String, String> from, Builder<Device> devices) { SCSI: for (int unit : new int[] { 0, 1, 2, 3, 4, 5, 6, 7 }) { String key = String.format("scsi:0:%d", unit); if (!from.containsKey(key)) break SCSI; devices.add(populateBuilder(new SCSIDevice.Builder(unit), key, from).build()); } }
public Map<String, ? extends Device> apply(Map<String, String> from) { Builder<Device> devices = ImmutableSet.builder(); addIDEDevices(from, devices); addSCSIDevices(from, devices); addBlockDevices(from, devices); return Maps.uniqueIndex(devices.build(), deviceToId); }
protected void addSCSIDevices(Map<String, String> from, Builder<Device> devices) { SCSI: for (int unit : new int[] { 0, 1, 2, 3, 4, 5, 6, 7 }) { String key = String.format("scsi:0:%d", unit); if (!from.containsKey(key)) break SCSI; devices.add(populateBuilder(new SCSIDevice.Builder(unit), key, from).build()); } }
protected void addIDEDevices(Map<String, String> from, Builder<Device> devices) { IDE: for (int bus : new int[] { 0, 1 }) for (int unit : new int[] { 0, 1 }) { String key = String.format("ide:%d:%d", bus, unit); if (!from.containsKey(key)) break IDE; devices.add(populateBuilder(new IDEDevice.Builder(bus, unit), key, from).build()); } }
protected void addBlockDevices(Map<String, String> from, Builder<Device> devices) { BLOCK: for (int index : new int[] { 0, 1, 2, 3, 4, 5, 6, 7 }) { String key = String.format("block:0:%d", index); if (!from.containsKey(key)) break BLOCK; devices.add(populateBuilder(new BlockDevice.Builder(index), key, from).build()); } }
protected void addBlockDevices(Map<String, String> from, Builder<Device> devices) { BLOCK: for (int index : new int[] { 0, 1, 2, 3, 4, 5, 6, 7 }) { String key = String.format("block:0:%d", index); if (!from.containsKey(key)) break BLOCK; devices.add(populateBuilder(new BlockDevice.Builder(index), key, from).build()); } }
protected void addSCSIDevices(Map<String, String> from, Builder<Device> devices) { SCSI: for (int unit : new int[] { 0, 1, 2, 3, 4, 5, 6, 7 }) { String key = String.format("scsi:0:%d", unit); if (!from.containsKey(key)) break SCSI; devices.add(populateBuilder(new SCSIDevice.Builder(unit), key, from).build()); } }
protected void addIDEDevices(Map<String, String> from, Builder<Device> devices) { IDE: for (int bus : new int[] { 0, 1 }) for (int unit : new int[] { 0, 1 }) { String key = String.format("ide:%d:%d", bus, unit); if (!from.containsKey(key)) break IDE; devices.add(populateBuilder(new IDEDevice.Builder(bus, unit), key, from).build()); } }