/** Creates new instance of {@link StockServiceResource} class. */ public StockServiceResource() { // creates test stock Stock stock = new Stock(); stock.setId(1L); stock.setName("Acme"); stock.setCode("ACM"); stock.setValue(new BigDecimal(37.5D)); stock.setDate(new Date()); stockMap.put(stock.getId(), stock); }
@Override public void updateStock(@PathParam("id") long id, Stock stock) { Stock current = stockMap.get(id); if (current == null) { throw new WebApplicationException(Response.Status.NOT_FOUND); } // updates the stock current.setName(stock.getName()); current.setCode(stock.getCode()); current.setDate(stock.getDate()); current.setValue(stock.getValue()); }