Package one.microstream.equality
Interface Equalator<T>
- Type Parameters:
T
- type of objects to compare
- All Known Subinterfaces:
HashEqualator<T>
,HashEqualator.IdentityHashEqualator<E>
,HashEqualator.ImmutableHashEqualator<E>
,HashEqualator.ImmutableValueTypeHashEqualator<E>
,HashEqualator.ValueTypeHashEqualator<E>
,IdentityEqualator<E>
,ValueTypeEqualator<E>
- All Known Implementing Classes:
Equalator.ComparatorWrapper
,Equalator.Sequence
,PersistenceTypeDescriptionMember.IdentityHashEqualator
,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 class
Equalator.ComparatorWrapper<T>
static interface
Equalator.Provider<T>
static class
Equalator.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)
boolean
equal(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 aPredicate
that 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 givenComparator
into 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:
true
if object1 equals object2,false
if not.
-
sample
Creates aPredicate
that 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 givenComparator
into anEqualator
. Resulting Equalator returnstrue
if the comparator return 0. In all other casesfalse
is 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
Equalator
and 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.
-