Package ch.bztf.m226blb1.Utils
Class ResponseHandler<T>
java.lang.Object
ch.bztf.m226blb1.Utils.ResponseHandler<T>
- Type Parameters:
T
- the body type
Handler for the response of the REST API.
- See Also:
-
Constructor Summary
ConstructorDescriptionResponseHandler
(String message, org.springframework.http.HttpStatus status) Constructor with the message and the status.ResponseHandler
(T data, String message, org.springframework.http.HttpStatus status) Constructor for all fields. -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.http.ResponseEntity<Object>
Creates a response entity from the current class.static org.springframework.http.ResponseEntity<Object>
generateResponse
(Object responseObj, String message, org.springframework.http.HttpStatus status) Creates a response entity with a data, message and status.static org.springframework.http.ResponseEntity<Object>
generateResponse
(String message, org.springframework.http.HttpStatus status) Creates a response entity with a message and status.
-
Constructor Details
-
ResponseHandler
Constructor with the message and the status.- Parameters:
message
- the messagestatus
- the status
-
ResponseHandler
Constructor for all fields.- Parameters:
data
- the data of type<T>
message
- the messagestatus
- thestatus
-
-
Method Details
-
generateResponse
Creates a response entity from the current class.- Returns:
- a response entity with all fields.
- See Also:
-
generateResponse
public static org.springframework.http.ResponseEntity<Object> generateResponse(String message, org.springframework.http.HttpStatus status) Creates a response entity with a message and status.- Parameters:
message
- the messagestatus
- the status- Returns:
- a response entity with all fields
- See Also:
-
generateResponse
public static org.springframework.http.ResponseEntity<Object> generateResponse(Object responseObj, String message, org.springframework.http.HttpStatus status) Creates a response entity with a data, message and status.- Parameters:
responseObj
- the datamessage
- the messagestatus
- the status- Returns:
- a response entity with all fields
-