Skip to content

Commit

Permalink
Task 27 : Add Java Doc for CustomResponse, CustomPaging, CustomPaging…
Browse files Browse the repository at this point in the history
…Request, CustomPagingResponse
  • Loading branch information
Rapter1990 committed Jul 2, 2024
1 parent 0122259 commit b897310
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;

/**
* Class named {@link CustomPagingRequest} representing a custom paging request.
*/
@Getter
@Setter
@SuperBuilder
Expand All @@ -16,6 +19,11 @@ public class CustomPagingRequest {

private CustomPaging pagination;

/**
* Converts the custom paging request to a Pageable object.
*
* @return the Pageable object
*/
public Pageable toPageable() {
return PageRequest.of(
Math.toIntExact(pagination.getPageNumber()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@

import java.util.List;

/**
* Class named {@link CustomPagingResponse} representing a custom paging response.
*
* @param <T> the type of content in the response
*/
@Getter
@Builder
public class CustomPagingResponse<T> {
Expand All @@ -20,8 +25,20 @@ public class CustomPagingResponse<T> {

private Integer totalPageCount;

/**
* Builder class for CustomPagingResponse.
*
* @param <T> the type of content in the response
*/
public static class CustomPagingResponseBuilder<T> {

/**
* Sets the fields of the CustomPagingResponseBuilder based on the provided CustomPage.
*
* @param customPage the CustomPage object
* @param <C> the type of content in the CustomPage
* @return the CustomPagingResponseBuilder
*/
public <C> CustomPagingResponseBuilder<T> of(final CustomPage<C> customPage) {
return CustomPagingResponse.<T>builder()
.pageNumber(customPage.getPageNumber())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@

import java.time.LocalDateTime;

/**
* Class named {@link CustomResponse} representing a custom response.
*
* @param <T> the type of the response content
*/
@Getter
@Builder
public class CustomResponse<T> {
Expand All @@ -27,7 +32,13 @@ public class CustomResponse<T> {
.isSuccess(true)
.build();


/**
* Creates a success response with the given content.
*
* @param response the response content
* @param <E> the type of the response content
* @return the CustomResponse object
*/
public static <E> CustomResponse<E> ok(E response) {
return CustomResponse.<E>builder()
.response(response)
Expand All @@ -36,6 +47,13 @@ public static <E> CustomResponse<E> ok(E response) {
.build();
}

/**
* Creates a created response with the given content.
*
* @param response the response content
* @param <E> the type of the response content
* @return the CustomResponse object
*/
@ResponseStatus(HttpStatus.CREATED)
public static <E> CustomResponse<E> created(E response) {
return CustomResponse.<E>builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
import lombok.Setter;
import lombok.experimental.SuperBuilder;

/**
* Class named {@link CustomPaging} representing custom paging information.
*/
@Getter
@Setter
@NoArgsConstructor
Expand All @@ -20,6 +23,11 @@ public class CustomPaging {
@Min(value = 1, message = "Page size must be bigger than 0")
private Integer pageSize;

/**
* Gets the zero-based page number.
*
* @return the zero-based page number
*/
public Integer getPageNumber() {
return pageNumber - 1;
}
Expand Down

0 comments on commit b897310

Please sign in to comment.