@Override public String apply(ProductItem productItem) { return productItem.getDescription(); } };
@Override public String apply(ProductItem productItem) { return productItem.getDescription(); } };
@Override public boolean apply(ProductItem productItem) { checkNotNull(productItem, "productItem cannot ne null"); return regex.matcher(productItem.getDescription()).matches(); }
@Override public boolean apply(ProductItem productItem) { checkNotNull(productItem, "productItem cannot ne null"); return regex.matcher(productItem.getDescription()).matches(); }
@Override public Volume apply(ProductItem item) { float volumeSize = ProductItems.capacity().apply(item); return new VolumeImpl( item.getId() + "", item.getDescription().indexOf(STORAGE_AREA_NETWORK) != -1 ? Volume.Type.SAN : Volume.Type.LOCAL, volumeSize, null, categoryCode(FIRST_GUEST_DISK).apply(item), false); } })).build();
@Override public Volume apply(ProductItem item) { float volumeSize = ProductItems.capacity().apply(item); return new VolumeImpl( item.getId() + "", item.getDescription().indexOf(STORAGE_AREA_NETWORK) != -1 ? Volume.Type.SAN : Volume.Type.LOCAL, volumeSize, null, categoryCode(FIRST_GUEST_DISK).apply(item), false); } })).build();
@Override public Hardware apply(Iterable<ProductItem> items) { ProductItem coresItem = getOnlyElement(filter(items, matches(cpuDescriptionRegex))); ProductItem ramItem = getOnlyElement(filter(items, categoryCode(RAM_CATEGORY))); ProductItem volumeItem = get(filter(items, categoryCode(FIRST_GUEST_DISK)), 0); String hardwareId = hardwareId().apply(ImmutableList.of(coresItem, ramItem, volumeItem)); double cores = ProductItems.capacity().apply(coresItem).doubleValue(); Matcher cpuMatcher = cpuDescriptionRegex.matcher(coresItem.getDescription()); double coreSpeed = (cpuMatcher.matches()) ? Double.parseDouble(cpuMatcher.group(cpuMatcher.groupCount())) : DEFAULT_CORE_SPEED; int ram = ProductItems.capacity().apply(ramItem).intValue(); return new HardwareBuilder().ids(hardwareId).processors(ImmutableList.of(new Processor(cores, coreSpeed))).ram( ram) .hypervisor("XenServer") .volumes( Iterables.transform(filter(items, categoryCodeMatches(diskCategoryRegex)), new Function<ProductItem, Volume>() { @Override public Volume apply(ProductItem item) { float volumeSize = ProductItems.capacity().apply(item); return new VolumeImpl( item.getId() + "", item.getDescription().indexOf(STORAGE_AREA_NETWORK) != -1 ? Volume.Type.SAN : Volume.Type.LOCAL, volumeSize, null, categoryCode(FIRST_GUEST_DISK).apply(item), false); } })).build(); }
@Override public Hardware apply(Iterable<ProductItem> items) { ProductItem coresItem = getOnlyElement(filter(items, matches(cpuDescriptionRegex))); ProductItem ramItem = getOnlyElement(filter(items, categoryCode(RAM_CATEGORY))); ProductItem volumeItem = get(filter(items, categoryCode(FIRST_GUEST_DISK)), 0); String hardwareId = hardwareId().apply(ImmutableList.of(coresItem, ramItem, volumeItem)); double cores = ProductItems.capacity().apply(coresItem).doubleValue(); Matcher cpuMatcher = cpuDescriptionRegex.matcher(coresItem.getDescription()); double coreSpeed = (cpuMatcher.matches()) ? Double.parseDouble(cpuMatcher.group(cpuMatcher.groupCount())) : DEFAULT_CORE_SPEED; int ram = ProductItems.capacity().apply(ramItem).intValue(); return new HardwareBuilder().ids(hardwareId).processors(ImmutableList.of(new Processor(cores, coreSpeed))).ram( ram) .hypervisor("XenServer") .volumes( Iterables.transform(filter(items, categoryCodeMatches(diskCategoryRegex)), new Function<ProductItem, Volume>() { @Override public Volume apply(ProductItem item) { float volumeSize = ProductItems.capacity().apply(item); return new VolumeImpl( item.getId() + "", item.getDescription().indexOf(STORAGE_AREA_NETWORK) != -1 ? Volume.Type.SAN : Volume.Type.LOCAL, volumeSize, null, categoryCode(FIRST_GUEST_DISK).apply(item), false); } })).build(); }
public Builder fromProductItem(ProductItem in) { return this .id(in.getId()) .description(in.getDescription()) .softwareDescriptionId(in.getSoftwareDescriptionId()) .softwareDescription(in.getSoftwareDescription()); } }
public Builder fromProductItem(ProductItem in) { return this .id(in.getId()) .description(in.getDescription()) .softwareDescriptionId(in.getSoftwareDescriptionId()) .softwareDescription(in.getSoftwareDescription()); } }
@Override public Image apply(ProductItem productItem) { checkNotNull(productItem, "productItem"); String description = checkNotNull(productItem.getDescription(), "productItem.description"); OsFamily osFamily = osFamily().apply(description); if (osFamily == OsFamily.UNRECOGNIZED) { logger.debug("Cannot determine os family for item: %s", productItem); } Integer bits = osBits().apply(description); if (bits == null) { logger.debug("Cannot determine os bits for item: %s", productItem); } String osVersion = osVersion().apply(description); if (osVersion == null) { logger.debug("Cannot determine os version for item: %s", productItem); } OperatingSystem os = OperatingSystem.builder() .description(description) .family(osFamily) .version(osVersion) .is64Bit(Objects.equal(bits, 64)) .build(); return new ImageBuilder() .ids(imageId().apply(productItem)) .description(description) .operatingSystem(os) .status(Image.Status.AVAILABLE) .build(); }
public Builder fromProductItem(ProductItem in) { return this .id(in.getId()) .description(in.getDescription()) .softwareDescriptionId(in.getSoftwareDescriptionId()) .softwareDescription(in.getSoftwareDescription()); } }
@Override public Image apply(ProductItem productItem) { checkNotNull(productItem, "productItem"); String description = checkNotNull(productItem.getDescription(), "productItem.description"); OsFamily osFamily = osFamily().apply(description); if (osFamily == OsFamily.UNRECOGNIZED) { logger.debug("Cannot determine os family for item: %s", productItem); } Integer bits = osBits().apply(description); if (bits == null) { logger.debug("Cannot determine os bits for item: %s", productItem); } String osVersion = osVersion().apply(description); if (osVersion == null) { logger.debug("Cannot determine os version for item: %s", productItem); } OperatingSystem os = OperatingSystem.builder() .description(description) .family(osFamily) .version(osVersion) .is64Bit(Objects.equal(bits, 64)) .build(); return new ImageBuilder() .ids(imageId().apply(productItem)) .description(description) .operatingSystem(os) .status(Image.Status.AVAILABLE) .build(); }
private void checkProductItem(ProductItem item) { assert item.getId() > 0 : item; assert item.getDescription() != null : item; checkCategories(item.getCategories()); // units and capacity may be null assertTrue(item.getPrices().size() >= 0); for (ProductItemPrice price : item.getPrices()) { // ProductItemPrice newDetails = // client.getProductItemPrice(prices.getId()); // assertEquals(item.getId(), newDetails.getId()); checkPrice(price); } }
public T fromProductItem(ProductItem in) { return this .id(in.getId()) .description(in.getDescription()) .units(in.getUnits()) .capacity(in.getCapacity()) .prices(in.getPrices()) .categories(in.getCategories()); } }
public T fromProductItem(ProductItem in) { return this .id(in.getId()) .description(in.getDescription()) .units(in.getUnits()) .capacity(in.getCapacity()) .prices(in.getPrices()) .categories(in.getCategories()); } }