Is it possible to merge iterators in Java? I have two iterators and I want to combine/merge them so that I could iterate though their elements in one go (in same loop) rathe
I would refactor the original design from:
Iterator pUsers = userService.getPrimaryUsersInGroup(group.getId()); Iterator sUsers = userService.getSecondaryUsersInGroup(group.getId());
To something like:
Iterator users = userService.getUsersInGroup(group.getId(), User.PRIMARY, User.SECONDARY, ...);