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 Superinterfaces:
CustomValueComparator<T>
public interface CustomPropertyComparator<T,C extends PropertyChange> extends CustomValueComparator<T>
Property-scope comparator bounded toCustomType
.
Custom Types are not easy to manage, use it as a last resort,
only for corner cases like comparing custom Collection types.
Typically, Custom Types are large structures (like Multimap).
Implementation should calculate diff between two objects of given Custom Type.
Usage:JaversBuilder.javers() .registerCustomType( Multimap.class, new GuavaCustomComparator()) .build()
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.util.Optional<C>
compare(T left, T right, PropertyChangeMetadata metadata, Property property)
Called by JaVers to calculate property-to-property diff between two Custom Type objects.-
Methods inherited from interface org.javers.core.diff.custom.CustomValueComparator
equals, handlesNulls, toString
-
-
-
-
Method Detail
-
compare
java.util.Optional<C> compare(T left, T right, PropertyChangeMetadata metadata, Property property)
Called by JaVers to calculate property-to-property diff between two Custom Type objects. Can calculate any of concretePropertyChange
.
Implementation ofcompare()
should be consistent withCustomValueComparator.equals(Object, Object)
. Whencompare()
returnsOptional.empty()
,equals()
should return false.- Parameters:
left
- left (or old) valueright
- right (or current) valuemetadata
- callPropertyChangeMetadata.getAffectedCdoId()
to get Id of domain object being comparedproperty
- property being compared- Returns:
- should return Optional.empty() if compared objects are the same
-
-