@Test public void testWrap() { long[] items = new long[10]; for (int i = 0; i < items.length; i++) { items[i] = (2300000000000000L + 101) + (items.length - 1 - i); } ApiLogger.debug(Arrays.toString(items)); int count = 20; long[] expecteds = Arrays.copyOf(items, items.length); PageWrapper<long[]> pageWrapper = PageWrapperUtil.wrap(items, count); ApiLogger.debug(PageWrapperUtil.toJson(pageWrapper, "ids", pageWrapper.result)); Assert.assertArrayEquals(expecteds, pageWrapper.result); }
public static PageWrapper<long[]> wrap(long[] ids, int count) { PageWrapper<long[]> wrapper = new PageWrapper<long[]>(0, 0, ids); wrapper.totalNumber = ids.length; if (ids.length > 1) { wrapper.nextCursor = ids[ids.length - 1] + MAX_ID_ADJECT; } wrapper.result = Arrays.copyOf(ids, Math.min(ids.length, count)); return wrapper; }
PageWrapperUtil { public static PageWrapper<long[]> wrap(long[] ids, int count) { PageWrapper<long[]> wrapper = new PageWrapper<long[]>(0, 0, ids); wrapper.totalNumber = ids.length; if (ids.length > 1) { wrapper.nextCursor = ids[ids.length - 1] + MAX_ID_ADJECT; } wrapper.result = Arrays.copyOf(ids, Math.min(ids.length, count)); return wrapper; } }
PageWrapperUtil { public static PageWrapper<long[]> wrap(long[] ids, int count) { PageWrapper<long[]> wrapper = new PageWrapper<long[]>(0, 0, ids); wrapper.totalNumber = ids.length; if (ids.length > 1) { wrapper.nextCursor = ids[ids.length - 1] + MAX_ID_ADJECT; } wrapper.result = Arrays.copyOf(ids, Math.min(ids.length, count)); return wrapper; }  }
PageWrapperUtil { public static PageWrapper<long[]> wrap(long[] ids, int count) { PageWrapper<long[]> wrapper = new PageWrapper<long[]>(0, 0, ids); wrapper.totalNumber = ids.length; if (ids.length > 1) { wrapper.nextCursor = ids[ids.length - 1] + MAX_ID_ADJECT; } wrapper.result = Arrays.copyOf(ids, Math.min(ids.length, count)); return wrapper; }  static String toJson(PageWrapper<T> pageWrapper, String name, long[] values); static String toJson(PageWrapper<T> pageWrapper, String name, Jsonable[] values); static PageWrapper<long[]> wrap(long[] ids, int count); static int getPageOffset(int page, int count); static PageWrapper<long[]> paginationAndReverse(long[] ids, PaginationParam paginationParam); static PageWrapper<long[]> paginationAndReverse(long[] ids, int idsLen, long sinceId, long maxId, int count, int page); static int[] calculatePaginationByReverse(long[] ids, int idsLen, long sinceId, long maxId, int count, int page); static void calculateCursorByReverse(PageWrapper<T> wrapper, long[] ids, int offset, int limit, int count); }
PageWrapperUtil { public static PageWrapper<long[]> wrap(long[] ids, int count) { PageWrapper<long[]> wrapper = new PageWrapper<long[]>(0, 0, ids); wrapper.totalNumber = ids.length; if (ids.length > 1) { wrapper.nextCursor = ids[ids.length - 1] + MAX_ID_ADJECT; } wrapper.result = Arrays.copyOf(ids, Math.min(ids.length, count)); return wrapper; }  static String toJson(PageWrapper<T> pageWrapper, String name, long[] values); static String toJson(PageWrapper<T> pageWrapper, String name, Jsonable[] values); static PageWrapper<long[]> wrap(long[] ids, int count); static int getPageOffset(int page, int count); static PageWrapper<long[]> paginationAndReverse(long[] ids, PaginationParam paginationParam); static PageWrapper<long[]> paginationAndReverse(long[] ids, int idsLen, long sinceId, long maxId, int count, int page); static int[] calculatePaginationByReverse(long[] ids, int idsLen, long sinceId, long maxId, int count, int page); static void calculateCursorByReverse(PageWrapper<T> wrapper, long[] ids, int offset, int limit, int count);  }