Builder<Hardware> hardware = ImmutableSortedSet.orderedBy(new Comparator<Hardware>() {
@Override
public int compare(Hardware h1, Hardware h2) {
List<? extends Volume> volumes1 = h1.getVolumes();
List<? extends Volume> volumes2 = h2.getVolumes();
ComparisonChain comparisonChain = ComparisonChain.start().compare(getCores(h1), getCores(h2))
.compare(h1.getRam(), h2.getRam())
.compare(getSpace(h1), getSpace(h2))
.compare(getBootableDeviceType(h1), getBootableDeviceType(h2));
if (!volumes1.isEmpty() && !volumes2.isEmpty() && volumes1.size() == volumes2.size()) {
for (int i = 0; i < volumes1.size(); i++) {
comparisonChain.compare(volumes1.get(i).getType(), volumes2.get(i).getType());
}
}
return comparisonChain.result();
}
});
for (VirtualGuestBlockDevice blockDevice : virtualGuestConfiguration.getVirtualGuestBlockDevices()) {
float capacity = blockDevice.getVirtualDiskImage().getCapacity();
Type type = blockDevice.getVirtualGuest().isLocalDiskFlag() ? Type.LOCAL : Type.SAN;