Skip to content

Commit f74dcee

Browse files
Replaced primitive longs with Wrapper Class Longs
1 parent bf738e0 commit f74dcee

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/main/java/com/answerdigital/answerking/controller/ProductController.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,15 @@ public ResponseEntity<Product> addProduct(@Valid @RequestBody final ProductReque
5252
}
5353

5454
@PutMapping("/{id}")
55-
public ResponseEntity<Product> updateProduct(@PathVariable @NotNull final long id,
55+
public ResponseEntity<Product> updateProduct(@PathVariable @NotNull final Long id,
5656
@Valid @RequestBody final ProductRequest productRequest,
5757
final Errors errors) {
5858
return new ResponseEntity<>(productService.updateProduct(id, productRequest),
5959
errors.hasErrors() ? HttpStatus.BAD_REQUEST : HttpStatus.OK);
6060
}
6161

6262
@DeleteMapping("/{id}")
63-
public ResponseEntity<Product> retireProduct(@PathVariable @NotNull final long id) {
63+
public ResponseEntity<Product> retireProduct(@PathVariable @NotNull final Long id) {
6464
return new ResponseEntity<>(productService.retireProduct(id), HttpStatus.OK);
6565
}
6666
}

src/main/java/com/answerdigital/answerking/service/ProductService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public List<Product> findAll() {
4242
return productRepository.findAll();
4343
}
4444

45-
public Product updateProduct(final long productId, final ProductRequest productRequest) {
45+
public Product updateProduct(final Long productId, final ProductRequest productRequest) {
4646
productRepository.findById(productId)
4747
.orElseThrow(() -> new NotFoundException(String.format("Product with ID %d does not exist.", productId)));
4848

@@ -54,7 +54,7 @@ public Product updateProduct(final long productId, final ProductRequest productR
5454
return productRepository.save(updatedProduct);
5555
}
5656

57-
public Product retireProduct(final long productId) {
57+
public Product retireProduct(final Long productId) {
5858
final Product product = findById(productId);
5959
if (product.isRetired()) {
6060
throw new RetirementException(String.format("The product with ID %d is already retired", productId));

0 commit comments

Comments
 (0)