aboutsummaryrefslogtreecommitdiffstats
path: root/container-search/src/main/java/com/yahoo/search/query/Properties.java
diff options
context:
space:
mode:
Diffstat (limited to 'container-search/src/main/java/com/yahoo/search/query/Properties.java')
-rw-r--r--container-search/src/main/java/com/yahoo/search/query/Properties.java51
1 files changed, 51 insertions, 0 deletions
diff --git a/container-search/src/main/java/com/yahoo/search/query/Properties.java b/container-search/src/main/java/com/yahoo/search/query/Properties.java
new file mode 100644
index 00000000000..df3d120c337
--- /dev/null
+++ b/container-search/src/main/java/com/yahoo/search/query/Properties.java
@@ -0,0 +1,51 @@
+// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package com.yahoo.search.query;
+
+import com.yahoo.search.Query;
+
+/**
+ * Object properties keyed by name which can be looked up using default values and
+ * with conversion to various primitive wrapper types.
+ * <p>
+ * Multiple property implementations can be chained to provide unified access to properties
+ * backed by multiple sources as a Chain of Responsibility.
+ * <p>
+ * For better performance, prefer CompoundName argument constants over Strings.
+ * <p>
+ * Properties can be cloned. Cloning a properties instance returns a new instance
+ * which chains new instances of all chained instances. The content within each instance
+ * is cloned to the extent determined appropriate by that implementation.
+ * <p>
+ * This base class simply passes all access on to the next in chain.
+ *
+ * @author bratseth
+ */
+public abstract class Properties extends com.yahoo.processing.request.Properties {
+
+ @Override
+ public Properties chained() { return (Properties)super.chained(); }
+
+ @Override
+ public Properties clone() {
+ return (Properties)super.clone();
+ }
+
+ /** The query owning this property object.
+ * Only guaranteed to work if this instance is accessible as query.properties()
+ */
+ public Query getParentQuery() {
+ if (chained() == null) {
+ throw new RuntimeException("getParentQuery should only be called on a properties instance accessible as query.properties()");
+ } else {
+ return chained().getParentQuery();
+ }
+ }
+
+ /**
+ * Invoked during deep cloning of the parent query.
+ */
+ public void setParentQuery(Query query) {
+ if (chained() != null)
+ chained().setParentQuery(query);
+ }
+}