I'm converting a Page to a new one by using PageImpl class, but the totalpages attribute has the default value 0. I would like to set totalPages to a specific number. Is it possible to change it?
code
public Page<InformationDTO> getInformationById(String classId, int page, int size) {
Pageable pageable = PageRequest.of(page, size);
List<Information> InformationList = informationRepository.findByClassIdOrderByCreateDateDesc(classId, pageable).getContent();
List<InformationDTO> InformationDTOList = new ArrayList<>();
if(!InformationList.isEmpty()){
for (Information information: informationList){
informationDTOList.add(new InformationDTO(information));
}
}
return new PageImpl<InformationDTO>(informationDTOList,pageable,informationList.size());
}