Package one.microstream.equality
Interface Equalator<T>
- Type Parameters:
T- type of objects to compare
- All Known Subinterfaces:
AddressHashEqualator,AnimalHashEqualator,HashEqualator<T>,HashEqualator.IdentityHashEqualator<E>,HashEqualator.ImmutableHashEqualator<E>,HashEqualator.ImmutableValueTypeHashEqualator<E>,HashEqualator.ValueTypeHashEqualator<E>,HumanHashEqualator,IdentityEqualator<E>,PetHashEqualator,ValueTypeEqualator<E>
- All Known Implementing Classes:
AddressHashEqualator.Default,AnimalHashEqualator.Default,Equalator.ComparatorWrapper,Equalator.Sequence,HumanHashEqualator.Default,PersistenceTypeDescriptionMember.IdentityHashEqualator,PetHashEqualator.Default,TypePair.HashEquality
public interface Equalator<T>
A equalator function which checks if two given objects are equal or not.
Since it is very close to the
Comparator, but has limited return value,
it is possible to wrap an existing comparator with the Wrap(Comparator) method.-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classEqualator.ComparatorWrapper<T>static interfaceEqualator.Provider<T>static classEqualator.Sequence<T>Useful for implementing SQL-like "GROUP BY" for collections. -
Method Summary
Modifier and Type Method Description static <E> Equalator<E>Chain(Equalator<? super E>... equalators)booleanequal(T object1, T object2)Compares the two given objects (object1 and object2) depending on the implementation.static <E> Equalator<E>identity()default Predicate<T>sample(T sample)Creates aPredicatethat checks every given object with equality against the set sample.static <E> Equalator<E>value()static <E> Equalator<E>Wrap(Comparator<? super E> comparator)Wraps a givenComparatorinto anEqualator.
-
Method Details
-
equal
Compares the two given objects (object1 and object2) depending on the implementation.- Parameters:
object1- as first object to check equality onobject2- as second object to check equality on- Returns:
trueif object1 equals object2,falseif not.
-
sample
Creates aPredicatethat checks every given object with equality against the set sample.- Parameters:
sample- which is compared- Returns:
- function that compares the input of the function with the given sample
-
Wrap
Wraps a givenComparatorinto anEqualator. Resulting Equalator returnstrueif the comparator return 0. In all other casesfalseis returned.- Type Parameters:
E- type of objects to compare- Parameters:
comparator- to wrap insinde a new Equalator- Returns:
- a new Equalator which executes the given comparator
-
Chain
- Type Parameters:
E- type of objects to compare- Parameters:
equalators- to chain together- Returns:
- Chained
Equalatorand only if all Equalators returntrue, this created Equalator returnstrue.
-
value
- Type Parameters:
E- type of objects to compare- Returns:
- Static equalator which defines equality through the
Object.equals(Object)method.
-
identity
- Type Parameters:
E- type of objects to compare- Returns:
- Static equalator which defines equality through the
'=='-Operator.
-