class UserRolesServiceImpl implements UserRolesService {

	@Override
	public Page<UserRolesResponse> getAllUserRoles(String searchTerm, int page, int size) {
		Page<UserRoles> userRoles = userRolesRepository.findAllUserRolesDetails(searchTerm, PageRequest.of(page, size));
		List<UserRolesResponse> allUserRolesList = Lists.newCopyOnWriteArrayList();
		userRoles.getContent().forEach(userRoleDetail -> {
			UserRolesResponse userRolesResponse = new UserRolesResponse();
			if(userRoleDetail != null){
				userRolesResponse.setCreatedBy(userRoleDetail.getOwner());
				userRolesResponse.setCreatedDate(userRoleDetail.getCreatedDate());
				userRolesResponse.setModifiedDate(userRoleDetail.getModifiedDate());
				userRolesResponse.setRoleId(userRoleDetail.getRoleId());
				userRolesResponse.setDescription(userRoleDetail.getRoleDesc());
				userRolesResponse.setRoleName(userRoleDetail.getRoleName());
				userRolesResponse.setUsers(userRoleDetail.getUsers().parallelStream().map(user -> user != null ? user.getUserId() : StringUtils.EMPTY).collect(Collectors.toList()));
				allUserRolesList.add(userRolesResponse);
			} 
		 });
		Page<UserRolesResponse> allUserRoles = new PageImpl<UserRolesResponse>(allUserRolesList, PageRequest.of(page, size), userRoles.getTotalElements());
		return allUserRoles;
	}

}