Skip to content

Commit

Permalink
feat: #159 SliceResponse 매퍼 메서드 추가 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
jaewonLeeKOR committed Sep 16, 2024
1 parent 180e637 commit 7c5f48c
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/main/java/com/server/capple/global/common/SliceResponse.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,19 @@ public SliceResponse(int number, int size, List<T> content, int numberOfElements
this.hasPrevious = hasPrevious;
this.hasNext = hasNext;
}

/**
* P : 데이터베이스에서 반환 받은 데이터 타입<BR>
* R : 사용자게에 반환할 데이터 타입
*/
public static <P, R> SliceResponse<R> toSliceResponse(Slice<P> sliceObject, List<R> content) {
return SliceResponse.<R>builder()
.number(sliceObject.getNumber())
.size(sliceObject.getSize())
.content(content)
.numberOfElements(sliceObject.getNumberOfElements())
.hasPrevious(sliceObject.hasPrevious())
.hasNext(sliceObject.hasNext())
.build();
}
}

0 comments on commit 7c5f48c

Please sign in to comment.