I've been told I should refactor the return type of this method in my controller so it doesnt return a generic <?> :
@GetMapping(value = "/{id}")
public ResponseEntity<?> getById(@PathVariable Long id) {
return myService.getById(id).map(ResponseEntity::ok).orElse(new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR));
}
myService.getById
returns an Optional<DestinyDTO>
, im confused about wether it is correct to return a ResponseEntity<Optional<DestinyDTO>>
or not. If so, how can i replace the <?>
return Type to match the actual return type in my service method getById.
Hopefully i explained myself. Any help is appreciated
You can return ResponseEntity<DestinyDTO>
.