예제 #1
0
 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");
   }
 }
예제 #2
0
 @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);
 }
예제 #3
0
 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;
 }
예제 #4
0
 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());
 }