-
Notifications
You must be signed in to change notification settings - Fork 613
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add groupByEachUniqueKey to RichIterable #1565
Comments
Hi @donraab I'd like to work on this issue. Could you please assign it to me. Thanks! |
Hi @pranukrish, done! |
Hi @donraab! So while trying to implement the functionality I realized that it has to be implemented in all the classes that inherit the RichIterable interface(and that's around a 100 classes) and I wanted to know if there is any work around to implementing this in all of these classes. |
Hi @pranukrish, yes adding a new method to I think the signature of this version of the method with a target map would look as follows:
Let me know if this makes sense or needs any clarification. Thanks! |
The other thing which can make this kind of change easier is searching for similar methods and putting the new method in the same classes. For example, putting this right below each groupByUniqueKey implementation. |
Thanks for the inputs @donraab and @motlin. I think I'll try a default implementation in RichIterable and see how that's working. And yes, I have implemented it with the same signature you mentioned. |
RichIterable currently has
groupBy
/groupByEach
but only hasgroupByUniqueKey
without the correspondinggroupByEachUniqueKey
. The methodgroupByEachUniqueKey
would index an item in aMap
using multiple keys. Each key will only point to one value. An example of this might be mapping a Person to his/her aliases.I ran into this problem recently trying to group an Object that contains a distinct range of numbers by each of the distinct numbers. I was able to accomplish this by using a nested
injectInto
, but it is somewhat awkward and may be difficult to comprehend. In my particular case, it is more optimal usinginjectInto
as I am grouping into anIntObjectMap
.The text was updated successfully, but these errors were encountered: