package com.wanari.utils.couchbase;

import org.springframework.data.domain.Pageable;

import java.util.List;

public class CouchbasePage<T> {
    public List<T> data;
    public long totalElements;
    public int pageNumber;
    public int size;
    public int totalPages;

    public CouchbasePage(Pageable pageable) {
        pageNumber = pageable.getPageNumber();
        size = pageable.getPageSize();
    }

    public void calculateTotalPages() {
        totalPages = ((int) totalElements - 1) / size + 1;
    }
}

@@ -102,16 +102,88 @@
 il.List;
+%0Aimport java.util.function.Function;%0Aimport java.util.stream.Collectors;
 %0A%0Apublic
@@ -340,16 +340,53 @@
 Pages;%0A%0A
+    private CouchbasePage() %7B%0A    %7D%0A%0A
     publ
@@ -525,100 +525,531 @@
    p
-ublic void calculateTotalPages() %7B%0A        totalPages = ((int) totalElements - 1) / size + 1
+rivate %3CU%3E CouchbasePage(CouchbasePage%3CU%3E other, Function%3CU, T%3E mapper) %7B%0A        data = other.data.stream().map(mapper).collect(Collectors.toList());%0A        totalElements = other.totalElements;%0A        pageNumber = other.pageNumber;%0A        size = other.size;%0A        totalPages = other.totalPages;%0A    %7D%0A%0A    public void calculateTotalPages() %7B%0A        totalPages = ((int) totalElements - 1) / size + 1;%0A    %7D%0A%0A    public %3CR%3E CouchbasePage%3CR%3E map(Function%3CT, R%3E mapper) %7B%0A        return new CouchbasePage%3C%3E(this, mapper)
 ;%0A  

Add mapper function for CouchbasePage