From 6c4f3a10c54a88432421ed40c24f88224b34cf01 Mon Sep 17 00:00:00 2001 From: Uwe Schindler Date: Mon, 15 Nov 2010 09:14:39 +0000 Subject: [PATCH] LUCENE-2757: Remove unneeded casts git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1035194 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/lucene/search/ScoringRewrite.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/lucene/src/java/org/apache/lucene/search/ScoringRewrite.java b/lucene/src/java/org/apache/lucene/search/ScoringRewrite.java index 255c1b651ab..03c3958dee0 100644 --- a/lucene/src/java/org/apache/lucene/search/ScoringRewrite.java +++ b/lucene/src/java/org/apache/lucene/search/ScoringRewrite.java @@ -55,7 +55,7 @@ public abstract class ScoringRewrite extends TermCollectingRewr * exceeds {@link BooleanQuery#getMaxClauseCount}. * * @see #setRewriteMethod */ - public final static RewriteMethod SCORING_BOOLEAN_QUERY_REWRITE = new ScoringRewrite() { + public final static ScoringRewrite SCORING_BOOLEAN_QUERY_REWRITE = new ScoringRewrite() { @Override protected BooleanQuery getTopLevelQuery() { return new BooleanQuery(true); @@ -93,14 +93,13 @@ public abstract class ScoringRewrite extends TermCollectingRewr public final static RewriteMethod CONSTANT_SCORE_BOOLEAN_QUERY_REWRITE = new RewriteMethod() { @Override public Query rewrite(IndexReader reader, MultiTermQuery query) throws IOException { - Query result = SCORING_BOOLEAN_QUERY_REWRITE.rewrite(reader, query); - assert result instanceof BooleanQuery; + final BooleanQuery bq = SCORING_BOOLEAN_QUERY_REWRITE.rewrite(reader, query); // TODO: if empty boolean query return NullQuery? - if (!((BooleanQuery) result).clauses().isEmpty()) { - // strip the scores off - result = new ConstantScoreQuery(new QueryWrapperFilter(result)); - result.setBoost(query.getBoost()); - } + if (bq.clauses().isEmpty()) + return bq; + // strip the scores off + final Query result = new ConstantScoreQuery(new QueryWrapperFilter(bq)); + result.setBoost(query.getBoost()); return result; }