summaryrefslogtreecommitdiffstats
path: root/container-search/src/main/java/com/yahoo/search/federation/sourceref/SearchChainInvocationSpec.java
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@yahoo-inc.com>2016-08-15 11:43:59 +0200
committerJon Bratseth <bratseth@yahoo-inc.com>2016-08-15 11:43:59 +0200
commitbf6ffad296a00eb5e0d130d798d799de28c69b1e (patch)
tree9c05fc7421309f75dd58255d0619ee75b4909f8d /container-search/src/main/java/com/yahoo/search/federation/sourceref/SearchChainInvocationSpec.java
parentf2dfe73196795211900f0d2053af6d6cc7411360 (diff)
Dedupe absolutely identical federation targets
Diffstat (limited to 'container-search/src/main/java/com/yahoo/search/federation/sourceref/SearchChainInvocationSpec.java')
-rw-r--r--container-search/src/main/java/com/yahoo/search/federation/sourceref/SearchChainInvocationSpec.java34
1 files changed, 32 insertions, 2 deletions
diff --git a/container-search/src/main/java/com/yahoo/search/federation/sourceref/SearchChainInvocationSpec.java b/container-search/src/main/java/com/yahoo/search/federation/sourceref/SearchChainInvocationSpec.java
index 7e82801d85f..c4d168af085 100644
--- a/container-search/src/main/java/com/yahoo/search/federation/sourceref/SearchChainInvocationSpec.java
+++ b/container-search/src/main/java/com/yahoo/search/federation/sourceref/SearchChainInvocationSpec.java
@@ -1,24 +1,30 @@
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.federation.sourceref;
+import com.google.common.collect.ImmutableList;
import com.yahoo.component.ComponentId;
import com.yahoo.search.searchchain.model.federation.FederationOptions;
import java.util.List;
+import java.util.Objects;
/**
* Specifices which search chain should be run and how it should be run.
+ * This is a value object.
*
* @author tonytv
*/
public class SearchChainInvocationSpec implements Cloneable {
+
public final ComponentId searchChainId;
+ /** The source to invoke, or null if none */
public final ComponentId source;
+ /** The provider to invoke, or null if none */
public final ComponentId provider;
public final FederationOptions federationOptions;
- public final List<String> documentTypes;
+ public final ImmutableList<String> documentTypes;
SearchChainInvocationSpec(ComponentId searchChainId,
ComponentId source, ComponentId provider, FederationOptions federationOptions,
@@ -27,11 +33,35 @@ public class SearchChainInvocationSpec implements Cloneable {
this.source = source;
this.provider = provider;
this.federationOptions = federationOptions;
- this.documentTypes = documentTypes;
+ this.documentTypes = ImmutableList.copyOf(documentTypes);
}
@Override
public SearchChainInvocationSpec clone() throws CloneNotSupportedException {
return (SearchChainInvocationSpec)super.clone();
}
+
+ @Override
+ public boolean equals(Object o) {
+ if (o == this) return true;
+ if ( ! ( o instanceof SearchChainInvocationSpec)) return false;
+
+ SearchChainInvocationSpec other = (SearchChainInvocationSpec)o;
+ if ( ! Objects.equals(this.searchChainId, other.searchChainId)) return false;
+ if ( ! Objects.equals(this.source, other.source)) return false;
+ if ( ! Objects.equals(this.provider, other.provider)) return false;
+ if ( ! Objects.equals(this.federationOptions, other.federationOptions)) return false;
+ if ( ! Objects.equals(this.documentTypes, other.documentTypes)) return false;
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ return searchChainId.hashCode() +
+ (source != null ? 3 * source.hashCode() : 0) +
+ (provider != null ? 5 * provider.hashCode(): 0) +
+ federationOptions.hashCode() +
+ documentTypes.hashCode();
+ }
+
}