Skip to content

Allow CustomValueComparators to handle nulls #1075

Description

@bartoszwalacik

Currently, before calling a CustomValueComparator impl, Javers checks nulls and assumes that :

null != any non-null value

This assumption simplifies an impl, but from the other hand it
makes impossible to write a Comparator which treats nulls as empty values.
See https://stackoverflow.com/questions/66497652/javers-comparison-string-collection-and-boolean-with-defined-rules

public interface CustomValueComparator<T> {
    /**
     * Called by JaVers to compare two Values.
     *
     * @param a not null
     * @param b not null
     */
    boolean equals(T a, T b);

New feature
Skip the Javers internal null-safety logic and allow passing nulls to CustomValueComparators.

Unfortunately it could break existing users' code

Test case
CaseWithCustomComparatorBlejwas.groovy

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions