Package io.github.jhipster.web.util
Interface ResponseUtil
-
public interface ResponseUtilUtility class for ResponseEntity creation.
-
-
Method Summary
Static Methods Modifier and Type Method Description static <X> org.springframework.http.ResponseEntity<X>wrapOrNotFound(Optional<X> maybeResponse)Wrap the optional into aResponseEntitywith anHttpStatus.OKstatus, or if it's empty, it returns aResponseEntitywithHttpStatus.NOT_FOUND.static <X> org.springframework.http.ResponseEntity<X>wrapOrNotFound(Optional<X> maybeResponse, org.springframework.http.HttpHeaders header)Wrap the optional into aResponseEntitywith anHttpStatus.OKstatus with the headers, or if it's empty, throws aResponseStatusExceptionwith statusHttpStatus.NOT_FOUND.
-
-
-
Method Detail
-
wrapOrNotFound
static <X> org.springframework.http.ResponseEntity<X> wrapOrNotFound(Optional<X> maybeResponse)
Wrap the optional into aResponseEntitywith anHttpStatus.OKstatus, or if it's empty, it returns aResponseEntitywithHttpStatus.NOT_FOUND.- Type Parameters:
X- type of the response- Parameters:
maybeResponse- response to return if present- Returns:
- response containing
maybeResponseif present orHttpStatus.NOT_FOUND
-
wrapOrNotFound
static <X> org.springframework.http.ResponseEntity<X> wrapOrNotFound(Optional<X> maybeResponse, org.springframework.http.HttpHeaders header)
Wrap the optional into aResponseEntitywith anHttpStatus.OKstatus with the headers, or if it's empty, throws aResponseStatusExceptionwith statusHttpStatus.NOT_FOUND.- Type Parameters:
X- type of the response- Parameters:
maybeResponse- response to return if presentheader- headers to be added to the response- Returns:
- response containing
maybeResponseif present - Throws:
org.springframework.web.server.ResponseStatusException-404 (Not found)ifmaybeResponseis empty
-
-