What is the best approach to transform a List into another List (e.g. in form `List<T> into another List<Pair<L,R>>`) as shown in the diagram:

[![enter image description here](https://i.stack.imgur.com/RYXjZ.jpg)](https://i.stack.imgur.com/RYXjZ.jpg)

As shown, there is a source List which is `List<UserModel>` which essentially contains a `UserModel` with `getUserId()` method, this list can either be empty, contains one or more elements), so it is arbitrary. The goal is to create another List, in which it will contain a pair of String User ID's.

Here's a code to outline the problem;

```
List<UserModel> models= getUsers(); 
List<UserRenderModel> renderModels = new LinkedList<>();

        IntStream.range(0, models)
                .forEach(idx -> {
                            UserRenderModel renderModel = new UserRenderModel();
                            UserModel dataModel = models.get(idx);
                            if(idx % 2 == 0) {
                             renderModel.setLeftUserId(dataModel.getUserId());
                            } else {
                             renderModel.setRightUserId(dataModel.getUserId());
                            }
                            renderModels.add(renderModel);
                        }
                );

```

In this code you can see that if we have a `UserModel` with two objects in the collection it will create two `UserRenderModel` that will be added to the renderModels collection which is wrong, whereas it should just be one `UserRenderModel`