I currently have this function:
ImmutableMap<String, ImmutableList<ImpactSummary>>
toSummariesByKey(ImmutableMap<String, ImmutableList<Impact>> impactsByKey)
return impactsByKey.entrySet().stream()
.collect(
toImmutableMap(
entry -> entry.getKey(),
entry -> helper(entry.getValue())));}
which makes use of this function:
ImmutableList<TierSummary> helper(
ImmutableList<Impact> impacts) {...}
As you can see, toSummariesByKey
simply calls helper
on each of the values in the input map.
Now, I need to modify toSummariesByKey
to take as argument, and return, an ImmutableListMultimap
instead:
ImmutableListMultimap<String, ImpactSummary> toSummariesByKey(
ImmutableListMultimap<String, Impact> impactsByKey) {...}
Reusing the body as is causes, when the helper function is called, the following error:
type
ImmutableList<Impact>
is not compatible withImpact
However, helper
is used in several places so I am reluctant to modify it. What is good practice in this scenario, please?
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745281846a4620322.html
评论列表(0条)