// given a set of Item objects, group them by the managers of creator and owners
Map<String, List<Item>> managersItems =
itemSet.parallelStream().flatMap(item -> {
// get the list of the creator and owners
List<String> users = new ArrayList();
users.add(item.getCreator());
users.addAll(item.getOwners());
return Stream.of(users.toArray(new String[] {})).map(user -> {
LdapUserInfo ldapUser = LdapUserInfoFactory.create(user);
String manager = ldapUser.getManager();
return new AbstractMap.SimpleImmutableEntry<String, Item(manager, item);
});
}).collect(
Collectors.groupingBy(Map.Entry::getKey, Collectors.mapping(Map.Entry::getValue, Collectors.toList())));
此代码在 Eclipse Mars 中编译良好,但在 Eclipse Luna 中出现以下错误:
类型不匹配:无法转换
Map<Object,List<Object>>
为Map<String,List<WeblabInfo>>
如果我没有在 Eclipse Luna中将返回的值分配给Map
with ,则错误是 at和带有消息的语句:Map<String, List<Item>> managersItem =
Map.Entry::getKey
Map.Entry::getValue
该类型
Map.Entry
未定义getKey(Object)
适用于此处的类型”。
我做错了什么?