Compare two Java Collections using Comparator instead of equals()

后端 未结 4 1266
臣服心动
臣服心动 2021-02-12 21:09

Problem Statement

I have two Collections of the same type of object that I want to compare. In this case, I want to compare them based on an attribute that does not fa

4条回答
  •  眼角桃花
    2021-02-12 21:28

    You can use new isEqualCollection method added to CollectionUtils since version 4. This method uses external comparsion mechanism provided by Equator interface implementation. Please, check this javadocs: CollectionUtils.isEqualCollection(...) and Equator.

提交回复
热议问题