public void delete(Beer beer) { logger.debug("Deleting beer: " + beer.toString()); if (beerMap.containsKey(beer.getId())) { beerMap.remove(beer.getId()); } else { throw new BeerNotFoundException( beer.getId(), "No beer with id = " + beer.getId() + " exists"); } }
@RequestMapping( value = "/update", consumes = Constants.APPLICATION_JSON, produces = Constants.APPLICATION_JSON, method = RequestMethod.POST) @ResponseStatus(HttpStatus.OK) public Beer updateBeer(@RequestBody Beer beer) { logger.debug("endpoint: .../update with payload: " + beer.toString()); return beerService.update(beer); }
public Beer update(Beer beer) { logger.debug("Updating beer: " + beer.toString()); if (beerMap.containsKey(beer.getId())) { beerMap.put(beer.getId(), beer); } else { throw new BeerNotFoundException( beer.getId(), "No beer with id = " + beer.getId() + " exists"); } return beer; }
public Beer create(Beer beer) { beer.setId(idSeq.getAndIncrement()); logger.debug("Creating beer: " + beer.toString()); beerMap.put(beer.getId(), beer); return beerMap.get(beer.getId()); }