リストからネストマップを作成しようとしています。以下、私は時間の誤差型不一致:Map <Object、Map <Object、List <ActorContents >>>からMap <Actor、Map <String、List <ActorContents >>>に変換できません。
型の不一致をコンパイル取得スニペットを使って:私は変更する場合に使用
Map<Actor,Map<String,List<ActorContents>>>
Map<Actor, List<String>> actorTypeOfContents = typeofContentforActor(genres, genreId);
Map<Actor, Map<String, List<ActorContents>>> imageMap1=
actorContents.stream()
.collect(Collectors.groupingBy(e -> e.getActor(), Collectors.groupingBy(p -> Utility.find(actorTypeOfContents.get(p.getActor()), i -> StringUtils.contains(p.getName(), "_" + i + "_"))
)));
ユーティリティメソッドに Map<Object,Map<Object,List<ActorContents>>>
から変換することはできませんすることなど
public static <T> T find(List<T> items, Predicate<T> matchFunction) {
for (T possibleMatch : items) {
if (matchFunction.test(possibleMatch)) {
return possibleMatch;
}
}
return null;
}
を下回っています以下のコードエラーはなく、コードは実行されます。
List<String> actorNames =actorTypeOfContents.get(Actor.Genre1);
Map<Actor, Map<String, List<ActorContents>>> imageMap1=
actorContents.stream()
.collect(Collectors.groupingBy(e -> e.getActor(), Collectors.groupingBy(p -> Utility.find(actorNames, i -> StringUtils.contains(p.getName(), "_" + i + "_"))
)));
あなたはあなたの助けが高く評価されて
Map<Actor, Map<String, List<ActorContents>>> imageMap1=
actorContents.stream()
.collect(Collectors.groupingBy(e -> e.getActor(), Collectors.groupingBy(p -> Utility.find(actorTypeOfContents.get(p.getActor()), i -> StringUtils.contains(p.getName(), "_" + i + "_"))
)));
スタックトレースを表示します。私たちはあなたの心を読むことができません。 –
これは、質問に記載されているコンパイル時エラーです。型不一致:Map
おそらく、2つのスニペットの間で異なるもの、つまり 'actorTypeOfContents.get(p.getActor()) 'に依存しているので、それが何かを知る必要があります。 – Radiodef