How to add values in BiMap JAVA 8?

387 Views Asked by At

I am trying to create a BiMap.

BiMap<Integer, Map<Item, Boolean>> rankedItem = HashBiMap.create();

            for (Catalogue catlogue : latestItemCataloug) {

                String name = catlogue.getName();

                List<Item> itemList = map.get(name);

                if (CollectionUtils.isNotEmpty(itemList)) {
                    itemList.stream().limit(max)
                            .peek(c -> c.setPrice(getPrice()))
                            .forEach(e -> {
                                Map<Item, Boolean> itemMap =
                                        new HashMap<>();
                                itemMap.put(e, true)
                                rankedItem.put(
                                        itemList.indexOf(e),
                                       );
                            });
                }
            }

It works fine but Is there a better way to do this? I am trying to improve my coding. Please suggests how can I optimize this Bi Map creation?

0

There are 0 best solutions below