Is there a Many to Many Collection in Java using Generics (Domain Model, not Persistence Layer)?

前端 未结 2 1904
耶瑟儿~
耶瑟儿~ 2021-02-05 08:13

I seem to be using the wrong search terms for this in Google...

I have written a Generic Class for Many-To-Many Associations, but I\'m guessing this has already been don

相关标签:
2条回答
  • 2021-02-05 08:50

    Looks like Apache Commons Multimap might be useful.

    EDIT: except it's one-to-many, not many-to-many. However, it still might be handy to use instead of your Map<T, List<S>> and Map<S, List<T>>, or as a reference.

    0 讨论(0)
  • 2021-02-05 09:02

    So far, this is a less trivial question than I thought. The two Java Collections extensions I know of off the top of my head are the Google one mentioned by duffymo, and the Apache Commons Collections. Neither has a many-to-many map. In Google's terminology, it would be a BiMultiMap; in Apache's, it would be a BidiMultiMap or MultiBidiMap.

    0 讨论(0)
提交回复
热议问题