blob: 43c4a2a1bbab28ed181a2f599b534b40099442a4 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.pagetemplates.engine;
import com.yahoo.search.result.ChainableComparator;
import com.yahoo.search.result.Hit;
import java.util.Comparator;
/**
* @author bratseth
*/
class RelevanceComparator extends ChainableComparator {
/**
* Creates a relevance comparator, with an optional secondary comparator.
* If the secondary is null, the intrinsic hit order is used as secondary.
*/
public RelevanceComparator(Comparator<Hit> secondaryComparator) {
super(secondaryComparator);
}
@Override
public int compare(Hit h1,Hit h2) {
int relevanceComparison=h2.getRelevance().compareTo(h1.getRelevance());
if (relevanceComparison!=0) return relevanceComparison;
return super.compare(h1,h2);
}
}
|