public final Object getValueAt(final int row, final int col) { long id = shopTable.getOffers().get(row).itemId; Item item = ItemStore.itemForId(id); long stock = shopTable.getOffers().get(row).amountAvailable; long in_inventory = inventory.getSlotWithItemId(id).getNumberOfItems(); int category = shownCategories.get(col); switch (category) { case ID: return id; case SYMBOL: return item.getId(); case NAME: return item.getName(); case VALUE: return item.getPrice(); case ATTACK: return item.getAttack(); case ARMOR: return item.getArmor(); case STOCK: return stock; case IN_INVENTORY: return in_inventory; default: return null; } }
/** * @param item item to search for * @return amount of items of this type */ public final long contains(final Item item) { if (null == item) { throw new IllegalArgumentException("item is null"); } long amount = slots .stream() .parallel() .mapToLong( slot -> { if (slot.getItem() != null && slot.getItem().getId() == item.getId()) { return slot.getAmount(); } return 0; }) .sum(); return amount; }