summaryrefslogtreecommitdiffstats
path: root/container-search/src/main/java/com/yahoo/prelude/query/CompositeTaggableItem.java
diff options
context:
space:
mode:
Diffstat (limited to 'container-search/src/main/java/com/yahoo/prelude/query/CompositeTaggableItem.java')
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/query/CompositeTaggableItem.java71
1 files changed, 71 insertions, 0 deletions
diff --git a/container-search/src/main/java/com/yahoo/prelude/query/CompositeTaggableItem.java b/container-search/src/main/java/com/yahoo/prelude/query/CompositeTaggableItem.java
new file mode 100644
index 00000000000..186f9686150
--- /dev/null
+++ b/container-search/src/main/java/com/yahoo/prelude/query/CompositeTaggableItem.java
@@ -0,0 +1,71 @@
+// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package com.yahoo.prelude.query;
+
+/**
+ * Common implementation for Item classes implementing the TaggableItem interface.
+ * Note that this file exist in 3 copies that should be kept in sync:
+ *
+ * CompositeTaggableItem.java
+ * SimpleTaggableItem.java
+ * TaggableSegmentItem.java
+ *
+ * These should only have trivial differences.
+ * (multiple inheritance or mixins would have been nice).
+ *
+ * @author arnej27959
+ */
+public abstract class CompositeTaggableItem extends CompositeItem implements TaggableItem {
+
+ public int getUniqueID() {
+ return uniqueID;
+ }
+
+ public void setUniqueID(int id) {
+ setHasUniqueID(true);
+ uniqueID = id;
+ }
+
+ /** See {@link TaggableItem#setConnectivity} */
+ public void setConnectivity(Item item, double connectivity) {
+ setHasUniqueID(true);
+ item.setHasUniqueID(true);
+ if (connectedItem != null) {
+ // untangle old connectivity
+ connectedItem.connectedBacklink = null;
+ }
+ this.connectivity = connectivity;
+ connectedItem = item;
+ connectedItem.connectedBacklink = this;
+ }
+
+ public Item getConnectedItem() {
+ return connectedItem;
+ }
+
+ public double getConnectivity() {
+ return connectivity;
+ }
+
+ public void setSignificance(double significance) {
+ setHasUniqueID(true);
+ setExplicitSignificance(true);
+ this.significance = significance;
+ }
+
+ public void setExplicitSignificance(boolean explicitSignificance) {
+ this.explicitSignificance = explicitSignificance;
+ }
+
+ public boolean hasExplicitSignificance() {
+ return explicitSignificance;
+ }
+
+ public double getSignificance() {
+ return significance;
+ }
+
+ //Change access privilege from protected to public.
+ public boolean hasUniqueID() {
+ return super.hasUniqueID();
+ }
+}