Package org.javers.core.diff.custom
Interface CustomPropertyComparator<T,C extends PropertyChange>
-
- Type Parameters:
T
- Custom TypeC
- Concrete type of PropertyChange returned by a comparator
- All Known Implementing Classes:
CustomBigDecimalComparator
public interface CustomPropertyComparator<T,C extends PropertyChange>
Property-scope comparator bounded toCustomType
.
Typically, Custom Types are large structures (like Multimap) or complex objects. For simple values, it's better to useCustomValueComparator
.
Implementation should calculate a diff between two objects of given Custom Type.
Examples and doc: https://javers.org/documentation/diff-configuration/#custom-comparators
Usage:JaversBuilder.javers().registerCustomComparator(new GuavaCustomComparator(), Multimap.class).build()
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.util.Optional<C>
compare(T left, T right, GlobalId affectedId, Property property)
Called by JaVers to calculate property-to-property diff between two Custom Type objects.boolean
equals(T a, T b)
Called by JaVers to calculate collection-to-collection diff, when Custom Type objects are Collection items.
-
-
-
Method Detail
-
compare
java.util.Optional<C> compare(T left, T right, GlobalId affectedId, Property property)
Called by JaVers to calculate property-to-property diff between two Custom Type objects.- Parameters:
left
- left (or old) valueright
- right (or current) valueaffectedId
- Id of domain object being comparedproperty
- property being compared- Returns:
- should return Optional.empty() if compared objects are the same
-
-