blob: 32a5644f29fb45b8c2897b4e3325fda076a77a07 (
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.federation.selection;
import java.util.Optional;
import com.yahoo.component.chain.Chain;
import com.yahoo.search.Searcher;
import com.yahoo.search.searchchain.model.federation.FederationOptions;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* Represents a search chain that the federation searcher should send a query to,
* along with a timeout and
* custom data reserved for use by the TargetSelector.
*
* @author tonytv
*/
public final class FederationTarget<T> {
private final Chain<Searcher> chain;
private final FederationOptions federationOptions;
private final T customData;
public FederationTarget(Chain<Searcher> chain, FederationOptions federationOptions, T customData) {
checkNotNull(chain);
checkNotNull(federationOptions);
this.chain = chain;
this.federationOptions = federationOptions;
this.customData = customData;
}
public Chain<Searcher> getChain() {
return chain;
}
public FederationOptions getFederationOptions() {
return federationOptions;
}
/**
* Any data that the TargetSelector wants to associate with this target.
* Owned exclusively by the TargetSelector that created this instance.
*/
public T getCustomData() {
return customData;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
FederationTarget that = (FederationTarget) o;
if (!chain.equals(that.chain)) return false;
if (customData != null ? !customData.equals(that.customData) : that.customData != null) return false;
if (!federationOptions.equals(that.federationOptions)) return false;
return true;
}
@Override
public int hashCode() {
int result = chain.hashCode();
result = 31 * result + federationOptions.hashCode();
return result;
}
}
|