com.quhaodian.user.utils.ConverResourceUtils Maven / Gradle / Ivy
package com.quhaodian.user.utils;
import com.quhaodian.data.core.Pagination;
import com.quhaodian.data.page.Page;
import com.quhaodian.data.rest.core.Conver;
import com.quhaodian.discover.rest.base.ResponseList;
import com.quhaodian.discover.rest.base.ResponsePage;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
/**
* Created by ada on 2017/5/23.
*/
public class ConverResourceUtils {
public ConverResourceUtils() {
}
public static void cover(ResponsePage result, Page pager) {
result.setNo(pager.getPageNumber());
result.setSize(pager.getPageSize());
result.setTotal((int) pager.getTotal());
result.setTotalPage(pager.getTotalPages());
}
public static void cover(ResponsePage result, Pagination pager) {
result.setNo(pager.getPageNo());
result.setSize(pager.getPageSize());
result.setTotal((int) pager.getTotalCount());
result.setTotalPage(pager.getTotalPage());
}
public static ResponsePage coverPage(ResponsePage result, Page pager, Conver conver) {
cover(result, pager);
List vos = new ArrayList();
List cs = pager.getContent();
if (cs != null) {
for (S item : cs) {
vos.add(conver.conver(item));
}
}
result.setList(vos);
return result;
}
public static ResponsePage coverPage(ResponsePage result, Pagination pager, Conver conver) {
cover(result, pager);
List vos = new ArrayList();
List cs = pager.getList();
if (cs != null) {
for (S item : cs) {
vos.add(conver.conver(item));
}
}
result.setList(vos);
return result;
}
public static ResponseList coverList(ResponseList result, Page pager, Conver conver) {
List vos = new ArrayList();
List cs = pager.getContent();
if (cs != null) {
for (S item : cs) {
vos.add(conver.conver(item));
}
}
result.setList(vos);
return result;
}
public static List coverList(List source, Conver conver) {
List vos = new ArrayList();
if (source != null) {
for (S item : source) {
vos.add(conver.conver(item));
}
}
return vos;
}
public static List coverCollect(Collection source, Conver conver) {
List vos = new ArrayList();
if (source != null) {
for (S item : source) {
vos.add(conver.conver(item));
}
}
return vos;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy