public Builder toBuilder() { return builder().fromProductItem(this); }
public Builder fromProductItem(ProductItem in) { return this .id(in.getId()) .description(in.getDescription()) .softwareDescriptionId(in.getSoftwareDescriptionId()) .softwareDescription(in.getSoftwareDescription()); } }
public ProductItem build() { return new ProductItem(id, description, units, capacity, prices, categories); }
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()); } }
@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();
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); } }
@Override public String apply(ProductItem productItem) { return productItem.getDescription(); } };
@Override public ProductItem apply(ProductItemPrice productItemPrice) { Set<ProductItemCategory> categories = productItemPrice.getCategories(); ProductItem item = productItemPrice.getItem(); ProductItem.Builder builder = productItemPrice.getItem().toBuilder(); if (item.getCategories().size() == 0 && categories.size() != 0) { builder.categories(categories); } return builder.build(); } };
@Override public boolean apply(ProductItem productItem) { checkNotNull(productItem, "productItem cannot ne null"); for (ProductItemCategory productItemCategory : productItem.getCategories()) { if (category.equals(productItemCategory.getCategoryCode())) return true; } return false; }
@Test public void testHardwareWithPrivateCore() { cpuItem = cpuItem.toBuilder() .description("Private 2 x 2.0 GHz Cores") .build(); Hardware hardware = toHardware.apply(ImmutableSet.of(cpuItem, ramItem, volumeItem)); assertEquals("123,456,789", hardware.getId()); List<? extends Processor> processors = hardware.getProcessors(); assertEquals(1, processors.size()); assertEquals(2.0, processors.get(0).getCores()); assertEquals(2, hardware.getRam()); List<? extends Volume> volumes = hardware.getVolumes(); assertEquals(1, volumes.size()); assertEquals(100F, volumes.get(0).getSize()); }
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()); } }
@Override public String apply(ProductItem productItem) { return productItem.getDescription(); } };
@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 ProductItem apply(ProductItemPrice productItemPrice) { Set<ProductItemCategory> categories = productItemPrice.getCategories(); ProductItem item = productItemPrice.getItem(); ProductItem.Builder builder = productItemPrice.getItem().toBuilder(); if (item.getCategories().size() == 0 && categories.size() != 0) { builder.categories(categories); } return builder.build(); } };
@Override public boolean apply(ProductItem productItem) { checkNotNull(productItem, "productItem cannot ne null"); for (ProductItemCategory productItemCategory : productItem.getCategories()) { if (category.matcher(productItemCategory.getCategoryCode()).matches()) return true; } return false; }
public Builder fromProductItem(ProductItem in) { return this .id(in.getId()) .description(in.getDescription()) .softwareDescriptionId(in.getSoftwareDescriptionId()) .softwareDescription(in.getSoftwareDescription()); } }
public Builder toBuilder() { return builder().fromProductItem(this); }
@Override public boolean apply(ProductItem productItem) { checkNotNull(productItem, "productItem cannot ne null"); return regex.matcher(productItem.getDescription()).matches(); }