1

I'm new to lambdaj so trying to get more used to it. I want to update this code using lambdaj:

 Passed in parameter Map<String, Device> devices;
 final Map<String, String> resultHash = new HashMap<String, String>();
        for (Device device : devices.values()) {
            result.put(device.getAddress(), device.getName());
        }

Thanks for you help

daverocks
  • 2,033
  • 4
  • 18
  • 22

1 Answers1

4
  1. index the devices based on their address, will give you a LambdaMap.
  2. transform the Device values of the LamdbaMap to their names, giving you a LambdaMap.

From the top of my mind:

LambdaCollections.with(devices.values())
    .index(Lambda.on(Device.class).getAddress())
    .convertValues(Lambda.on(Device.class).getName());
Hiery Nomus
  • 15,786
  • 2
  • 36
  • 31