Skip to content

Commit

Permalink
Task 36 : Revise CustomPageToCustomPagingResponseMapper
Browse files Browse the repository at this point in the history
  • Loading branch information
Rapter1990 committed Jul 2, 2024
1 parent 396ac25 commit 9b12dfd
Showing 1 changed file with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.springboot.ratelimiter.common.model.mapper;


import com.springboot.ratelimiter.common.model.dto.response.CustomPagingResponse;
import com.springboot.ratelimiter.common.model.page.CustomPage;
import com.springboot.ratelimiter.user.User;
Expand All @@ -11,13 +12,20 @@
import java.util.List;
import java.util.stream.Collectors;


/**
* Mapper named {@link CustomPageToCustomPagingResponseMapper} for converting CustomPage to CustomPagingResponse.
*/
@Mapper
public interface CustomPageToCustomPagingResponseMapper {

UserToUserResponseMapper userToUserResponseMapper = Mappers.getMapper(UserToUserResponseMapper.class);


/**
* Converts a CustomPage of User to a CustomPagingResponse of UserResponse.
*
* @param userPage the CustomPage object
* @return the CustomPagingResponse object
*/
default CustomPagingResponse<UserResponse> toPagingResponse(CustomPage<User> userPage) {

if (userPage == null) {
Expand All @@ -34,6 +42,12 @@ default CustomPagingResponse<UserResponse> toPagingResponse(CustomPage<User> use

}

/**
* Converts a list of User to a list of UserResponse.
*
* @param users the list of User objects
* @return the list of UserResponse objects
*/
default List<UserResponse> toUserResponseList(List<User> users) {

if (users == null) {
Expand All @@ -46,6 +60,11 @@ default List<UserResponse> toUserResponseList(List<User> users) {

}

/**
* Initializes the CustomPageToCustomPagingResponseMapper.
*
* @return the CustomPageToCustomPagingResponseMapper instance
*/
static CustomPageToCustomPagingResponseMapper initialize() {
return Mappers.getMapper(CustomPageToCustomPagingResponseMapper.class);
}
Expand Down

0 comments on commit 9b12dfd

Please sign in to comment.