我剛開始看着LambdaJ,並立即遇到了問題。我不認爲我做了什麼奇怪的事,但我無法弄清楚如何做到這一點。LambdaJ index()和密鑰類型轉換
我有管理員列表:
List<Administrator> allAdmins;
我有地圖我希望這些管理員映射到:
Map<String, Administrator> adminIdToAdmin = new HashMap<String, Administrator>();
的問題是,在管理類ID是多頭,不是絃樂。所以,我嘗試了以下內容:
adminIdToAdmin = index(allAdmins, on(Administrator.class).getAdministratorId().toString());
哪個不起作用。它與失敗:
ch.lambdaj.function.argument.ArgumentConversionException: Unable to convert the placeholder -2147483647 in a valid argument
at ch.lambdaj.function.argument.ArgumentsFactory.actualArgument(ArgumentsFactory.java:92)
at ch.lambdaj.function.convert.ArgumentConverter.<init>(ArgumentConverter.java:29)
at ch.lambdaj.Lambda.index(Lambda.java:1133)
如果我改變我的地圖包含龍和擺脫toString(),錯誤消失。
什麼是正確的方法來做到這一點?