Package com.yahoo.search.result
Class ChainableComparator
- java.lang.Object
-
- com.yahoo.search.result.ChainableComparator
-
- All Implemented Interfaces:
Comparator<Hit>
- Direct Known Subclasses:
FieldComparator
,HitGroupsLastComparator
,MetaHitsFirstComparator
public abstract class ChainableComparator extends Object implements Comparator<Hit>
Superclass of hit comparators which delegates comparisons of hits which are equal according to this comparator, to a secondary comparator.- Author:
- bratseth
-
-
Constructor Summary
Constructors Constructor Description ChainableComparator(Comparator<Hit> secondaryComparator)
Creates this comparator, given a secondary comparator, or null if there is no secondary
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compare(Hit first, Hit second)
Returns the comparison form the secondary comparison, or 0 if the secondary is null.Comparator<Hit>
getSecondaryComparator()
Returns the comparator to use to compare hits which are equal according to this, or null if none-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.Comparator
equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
-
-
-
Constructor Detail
-
ChainableComparator
public ChainableComparator(Comparator<Hit> secondaryComparator)
Creates this comparator, given a secondary comparator, or null if there is no secondary
-
-
Method Detail
-
getSecondaryComparator
public Comparator<Hit> getSecondaryComparator()
Returns the comparator to use to compare hits which are equal according to this, or null if none
-
compare
public int compare(Hit first, Hit second)
Returns the comparison form the secondary comparison, or 0 if the secondary is null. When overriding this in the subclass, alwaysreturn super.compare(first,second)
at the end of the subclass' implementation.- Specified by:
compare
in interfaceComparator<Hit>
-
-