@Before("audited(product, quantity)") public void audit(JoinPoint jp, Product product, int quantity) { System.out.println( "Audit: operation = " + jp.getSignature().getName() + " product = " + product.getName() + " quantity = " + quantity); }
public void removeProduct(Product product, int quantity) { if (isProductAvailable(product, quantity)) { InventoryItem inventoryItem = inventoryRepository.findByProduct(product); inventoryItem.deplete(quantity); } else { throw new InventoryException( "Insufficient inventory to fulfil" + " request for " + product.getName() + " quantity " + quantity); } }
public void removeProduct(Product product, int quantity) { InventoryItem inventoryItem = inventory.get(product.getId()); inventoryItem.deplete(quantity); }
@ReadOnly public boolean isProductAvailable(Product product, int quantity) { InventoryItem inventoryItem = inventory.get(product.getId()); return inventoryItem.getQuantityOnHand() >= quantity; }
public void addProduct(Product product, int quantity) { InventoryItem inventoryItem = inventory.get(product.getId()); inventoryItem.replenish(quantity); }