I have written simple rest application using Spring MVC 4 (or Spring-Boot). Within the controller I have return ResponseEntity. But in some cases I want to give
ResponseEntity
Its possible to return ResponseEntity without using generics, such as follows,
public ResponseEntity method() { boolean isValid = // some logic if (isValid){ return new ResponseEntity(new Success(), HttpStatus.OK); } else{ return new ResponseEntity(new Error(), HttpStatus.BAD_REQUEST); } }