public static SizeUnit maxUnitInList(List<Pair<SizeUnit, Double>> operands) { SizeUnit maxUnit = SizeUnit.getMinHandledUnit(); for(Pair<SizeUnit, Double> operand : operands) { if(operand.getFirst().getUnitWeight() > maxUnit.getUnitWeight()) { maxUnit = operand.getFirst(); } } return maxUnit; }
public static SizeUnit leastUnitInList(List<Pair<SizeUnit, Double>> operands) { SizeUnit leastUnit = SizeUnit.getMaxHandledUnit(); for(Pair<SizeUnit, Double> operand : operands) { if(operand.getFirst().getUnitWeight() < leastUnit.getUnitWeight()) { leastUnit = operand.getFirst(); } } return leastUnit; }
/** * Find a device in the map with the given type. */ public static VmDevice findVmDeviceByType(Map<?, VmDevice> vmManagedDeviceMap, VmDeviceType type) { return findVmDeviceByType(vmManagedDeviceMap, type.getName()); }
private String formatDataWritten(UIMessages messages, long totalBytesWritten, long bytesWrittenInCurrentInterval) { Pair<SizeUnit, Double> dataWrittenInCurrentInterval = SizeConverter.autoConvert(bytesWrittenInCurrentInterval, SizeUnit.BYTES); Pair<SizeUnit, Double> dataWritten = SizeConverter.autoConvert(totalBytesWritten, SizeUnit.BYTES); return messages.bytesWrittenInCurrentProfileInterval(formatSize(dataWrittenInCurrentInterval.getSecond()), dataWrittenInCurrentInterval.getFirst().toString(), formatSize(dataWritten.getSecond()), dataWritten.getFirst().toString()); }
public static Pair<Long, TimeUnit> autoConvert(long interval, TimeUnit fromUnit) { Pair<Long, TimeUnit> result = new Pair<>(); for (TimeUnit timeUnit : orderedTimeUnits) { long tInterval = interval; interval = convert(interval, fromUnit, timeUnit); if (interval >= 1) { result.setFirst(interval); result.setSecond(timeUnit); break; } interval = tInterval; } return result; } }
@Override public PairQueryableId getQueryableId() { return new PairQueryableId(getMemberId(getFirst()), getMemberId(getSecond())); }
protected String convertStringToIpv4Address(String subnetB) { return getIpAddressConverter().convertPrefixToNetmask(subnetB); }
/** * Check if device with the general type given exists in the map. */ public static boolean isVmDeviceExists(Map<Guid, VmDevice> vmManagedDeviceMap, VmDeviceGeneralType generalType) { return findVmDeviceByGeneralType(vmManagedDeviceMap, generalType) != null; }
private void runConvertPrefixToIpv4Address(String expectedIpv4Address, String prefix){ String errorMessage = String.format("Fail to convert prefix %s to IPv4 address: %s.", prefix, expectedIpv4Address); String actualIpv4Address = underTest.convertPrefixToNetmask(prefix); runTest(errorMessage, expectedIpv4Address, actualIpv4Address); }
private void runIpAddressConversionToLong(String Ipv4Address, long expectedIpAddressAsLong){ String errorMessage = String.format("Fail to convert IPv4 Address: %s to long.", Ipv4Address); long actualIpAddressAsLongResult = underTest.convertIpAddressToLong(Ipv4Address); runTest(errorMessage, expectedIpAddressAsLong, actualIpAddressAsLongResult); }
@Test public void valueInRange() { initConfiguredRange(); validateAndAssertResult(new ConfiguredRangeContainer(TEST_IN_RANGE), true); }
public Map<Guid, Set<NetworkAttachment>> byNicId() { return groupMultipleValues(new ByNicId(), networkAttachments); }
public Map<Guid, NetworkAttachment> byNetworkId() { return group(new ByNetworkId(), networkAttachments); }
/** * Check if device with the type given exists in the map. */ public static boolean isVmDeviceExists(Map<Guid, VmDevice> vmManagedDeviceMap, VmDeviceType type) { return findVmDeviceByType(vmManagedDeviceMap, type) != null; }
public static boolean isSoundDeviceExists(Collection<VmDevice> devices) { for (VmDevice device : devices) { if (isSound(device)) { return true; } } return false; }
@Override public String toString() { return ToStringBuilder.forInstance(this) .append("SPM Id", spmId) .append("SPM LVER", spmLVER) .append("SPM Status", spmStatus) .build(); } }
@Override public String toString() { return ToStringBuilder.forInstance(this) .append("id", id) .append("status", status) .build(); } }