Skip to content
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

CustomPropertyComparator should be used compare Collection items #747

bartoszwalacik opened this issue Nov 25, 2018 · 5 comments


Copy link

bartoszwalacik commented Nov 25, 2018

Currently, CustomPropertyComparator is used only for comparing object properties, for example, it can be used to compare Person objects in boss property:

class Company {
        private Person boss
        private List<Person> partners

But it is not used by JaVers to compare Person objects when they are collection items in the partners List.

Possible solution is a new method in CustomPropertyComparator with default impl:

     * This comparator is called by JaVers to calculate collection-to-collection diff.
     * <br/>
     * For example, when objects of type T are List items.
     * <br/><br/>
     * Both equals() and compare() should return consistent results. When compare() returns null,
     * equals() should return false.
    default boolean equals(T a, T b) {
        return Objects.equals(a, b);
Copy link
Member Author

released in 4.0.0-RC3

Copy link

Works with ListCompareAlgorithm.SIMPLE
Assert fails for ListCompareAlgorithm.AS_SET and LEVENSHTEIN_DISTANCE.
Test-Project available at

Copy link
Member Author

omg, so we need a fix ...

bartoszwalacik added a commit that referenced this issue Dec 3, 2018
bartoszwalacik added a commit that referenced this issue Dec 5, 2018
Copy link
Member Author

Fixed in 5.0.1 when CustomPropertyComparator is used with LEVENSHTEIN.
CustomPropertyComparator can't be used with AS_SET because for comparing Sets, we need both equals() and hashCode() and CustomPropertyComparator implements only custom equals()

Copy link

dmitry-weirdo commented Nov 25, 2020

@bartoszwalacik any perspective to also be able to use CustomPropertyComparator together with CustomPropertyComparator?

I described my case on #1038.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

No branches or pull requests

3 participants