2012-08-10 63 views
1

我是新來的lambdaj,所以試圖更習慣它。我想更新該代碼使用lambdaj: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()); 
     } 

感謝您幫助

回答

4
  1. 指數基於地址的設備,一定會給你一個LambdaMap。
  2. 將LamdbaMap的Device值轉換爲它們的名稱,爲您提供LambdaMap。

從我的腦海的頂部:

LambdaCollections.with(devices.values()) 
    .index(Lambda.on(Device.class).getAddress()) 
    .convertValues(Lambda.on(Device.class).getName()); 
相關問題