@RequestMapping(value = "/customers/{id}", method = RequestMethod.DELETE) ResponseEntity<?> delete(@PathVariable Long id) { return this.customerRepository .findById(id) .map( c -> { customerRepository.delete(c); return ResponseEntity.noContent().build(); }) .orElseThrow(() -> new CustomerNotFoundException(id)); }