Permalink
Browse files

Remove duplicate lucene logic

  • Loading branch information...
1 parent 3eaa5c2 commit 5baa9ec576379ba2ff91921582401e552ec67183 @johnktims johnktims committed with Shredder121 Dec 28, 2015
@@ -18,6 +18,7 @@
import java.io.StringReader;
import java.util.Arrays;
+import java.util.Set;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.document.Document;
@@ -39,6 +40,7 @@
import org.junit.Ignore;
import org.junit.Test;
+import com.google.common.collect.Sets;
import com.querydsl.core.*;
import com.querydsl.core.types.*;
import com.querydsl.core.types.dsl.*;
@@ -78,6 +80,9 @@
private IndexWriter writer;
private IndexSearcher searcher;
+ private static final Set<? extends Operator> UNSUPPORTED_OPERATORS = Sets.immutableEnumSet(Ops.STARTS_WITH_IC,
+ Ops.EQ_IGNORE_CASE, Ops.ENDS_WITH_IC, Ops.STRING_CONTAINS_IC);
+
private final QueryMetadata metadata = new DefaultQueryMetadata();
private Document createDocument() {
@@ -635,14 +640,7 @@ public void pathAny() throws Exception {
}
private boolean unsupportedOperation(Predicate filter) {
- if (filter instanceof Operation<?>) {
- Operator op = ((Operation<?>) filter).getOperator();
- if (op == Ops.STARTS_WITH_IC || op == Ops.EQ_IGNORE_CASE || op == Ops.STARTS_WITH_IC
- || op == Ops.ENDS_WITH_IC || op == Ops.STRING_CONTAINS_IC) {
- return true;
- }
- }
- return false;
+ return UNSUPPORTED_OPERATORS.contains(((Operation<?>) filter).getOperator());
}
@Test
@@ -18,6 +18,7 @@
import java.io.StringReader;
import java.util.Arrays;
+import java.util.Set;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.document.*;
@@ -36,6 +37,7 @@
import org.junit.Ignore;
import org.junit.Test;
+import com.google.common.collect.Sets;
import com.querydsl.core.*;
import com.querydsl.core.types.*;
import com.querydsl.core.types.dsl.*;
@@ -75,6 +77,9 @@
private IndexWriter writer;
private IndexSearcher searcher;
+ private static final Set<? extends Operator> UNSUPPORTED_OPERATORS = Sets.immutableEnumSet(Ops.STARTS_WITH_IC,
+ Ops.EQ_IGNORE_CASE, Ops.ENDS_WITH_IC, Ops.STRING_CONTAINS_IC);
+
private final QueryMetadata metadata = new DefaultQueryMetadata();
private Document createDocument() {
@@ -637,14 +642,7 @@ public void pathAny() throws Exception {
}
private boolean unsupportedOperation(Predicate filter) {
- if (filter instanceof Operation<?>) {
- Operator op = ((Operation<?>) filter).getOperator();
- if (op == Ops.STARTS_WITH_IC || op == Ops.EQ_IGNORE_CASE || op == Ops.STARTS_WITH_IC
- || op == Ops.ENDS_WITH_IC || op == Ops.STRING_CONTAINS_IC) {
- return true;
- }
- }
- return false;
+ return UNSUPPORTED_OPERATORS.contains(((Operation<?>) filter).getOperator());
}
@Test
@@ -18,6 +18,7 @@
import java.io.StringReader;
import java.util.Arrays;
+import java.util.Set;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.document.Document;
@@ -41,6 +42,7 @@
import org.junit.Ignore;
import org.junit.Test;
+import com.google.common.collect.Sets;
import com.querydsl.core.BooleanBuilder;
import com.querydsl.core.DefaultQueryMetadata;
import com.querydsl.core.MatchingFiltersFactory;
@@ -95,6 +97,9 @@
private IndexWriter writer;
private IndexSearcher searcher;
+ private static final Set<? extends Operator> UNSUPPORTED_OPERATORS = Sets.immutableEnumSet(Ops.STARTS_WITH_IC,
+ Ops.EQ_IGNORE_CASE, Ops.ENDS_WITH_IC, Ops.STRING_CONTAINS_IC);
+
private final QueryMetadata metadata = new DefaultQueryMetadata();
private Document createDocument() {
@@ -712,15 +717,7 @@ public void pathAny() throws Exception {
}
private boolean unsupportedOperation(Predicate filter) {
- if (filter instanceof Operation<?>) {
- Operator op = ((Operation<?>) filter).getOperator();
- if (op == Ops.STARTS_WITH_IC || op == Ops.EQ_IGNORE_CASE
- || op == Ops.STARTS_WITH_IC || op == Ops.ENDS_WITH_IC
- || op == Ops.STRING_CONTAINS_IC) {
- return true;
- }
- }
- return false;
+ return UNSUPPORTED_OPERATORS.contains(((Operation<?>) filter).getOperator());
}
@Test

0 comments on commit 5baa9ec

Please sign in to comment.