Skip to content

Commit

Permalink
perf($starter): don't wrap int value
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnymillergh committed Sep 17, 2021
1 parent 5d1da14 commit 8442f49
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class ResponseBodyBean<T> implements Serializable {
/**
* Default status is 200 OK.
*/
private Integer status = HttpStatus.OK.value();
private int status = HttpStatus.OK.value();
/**
* The Message. Default: 200 OK.
*/
Expand All @@ -49,6 +49,9 @@ public class ResponseBodyBean<T> implements Serializable {
*/
private T data;

private ResponseBodyBean() {
}

/**
* <p>Respond to client with IUniversalStatus (status may be OK or other).</p>
* <p><strong>ATTENTION:</strong></p>
Expand Down Expand Up @@ -112,7 +115,7 @@ public static <T> ResponseBodyBean<T> ofStatus(@NonNull final HttpStatus status,
* @param data data to be responded
* @return response body for ExceptionControllerAdvice
*/
public static <T> ResponseBodyBean<T> ofStatus(@NonNull final Integer status, @NonNull final String message,
public static <T> ResponseBodyBean<T> ofStatus(final int status, @NonNull final String message,
@Nullable final T data) {
ResponseBodyBean<T> responseBodyBean = new ResponseBodyBean<>();
responseBodyBean.setStatus(status);
Expand All @@ -132,7 +135,7 @@ public static <T> ResponseBodyBean<T> ofStatus(@NonNull final Integer status, @N
* @param data data to be responded
* @return response body
*/
public static <T> ResponseBodyBean<T> setResponse(@NonNull final Integer status, @NonNull final String message,
public static <T> ResponseBodyBean<T> setResponse(final int status, @NonNull final String message,
@Nullable final T data)
throws BaseException {
if (!HttpStatus.valueOf(status).is2xxSuccessful()) {
Expand Down Expand Up @@ -276,7 +279,7 @@ public static <T, B extends BaseException> ResponseBodyBean<T> ofException(@NonN
* @return the json
* @author Johnny Miller (锺俊), email: johnnysviva@outlook.com, date: 12/22/2020 10:16 AM
*/
public static JSON of(@NonNull String message, @Nullable Object data, @NonNull Integer status) {
public static JSON of(@NonNull String message, @Nullable Object data, int status) {
val responseBodyBean = ResponseBodyBean.ofStatus(status, message, data);
val config = new JSONConfig();
config.setIgnoreNullValue(false).setDateFormat(UniversalDateTime.DATE_TIME_FORMAT);
Expand Down

0 comments on commit 8442f49

Please sign in to comment.