Apache Lucene open-source search software
LUCENE-1630: make Query.createQueryWeight optional, with default impl to wrap existing createWeight
Michael McCandlessec88b1578dd8
diff --git a/src/java/org/apache/lucene/search/Query.java b/src/java/org/apache/lucene/search/Query.javaindex 9fa1b5f2571..1d4ae35bb8b 100644--- a/src/java/org/apache/lucene/search/Query.java+++ b/src/java/org/apache/lucene/search/Query.java@@ -88,18 +88,24 @@ public abstract class Query implements java.io.Serializable, Cloneable {* @deprecated use {@link #createQueryWeight(Searcher)} instead.*/protected Weight createWeight(Searcher searcher) throws IOException {- return createQueryWeight(searcher);+ throw new UnsupportedOperationException();}/*** Expert: Constructs an appropriate {@link QueryWeight} implementation for* this query.- ** <p>* Only implemented by primitive queries, which re-write to themselves.+ * <p>+ * <b>NOTE:</b> in 3.0 this method will throw+ * {@link UnsupportedOperationException}. It is implemented now by calling+ * {@link #createWeight(Searcher)} for backwards compatibility, for+ * {@link Query} implementations that did not override it yet (but did+ * override {@link #createWeight(Searcher)}).*/+ // TODO (3.0): change to throw UnsupportedOperationException.public QueryWeight createQueryWeight(Searcher searcher) throws IOException {- throw new UnsupportedOperationException();+ return new QueryWeightWrapper(weight(searcher));}/**