jenkins-bot has submitted this change and it was merged. Change subject: Adding project lombok support ......................................................................
Adding project lombok support Adding automatic generation of getters, setters, equals and hashCode. Note that your IDE probably needs support to handle lombok correctly. Eclipse and IntelliJ both have plugin for it. If IDE support is an issue, we probably do not want to merge this. See https://projectlombok.org/ for an introduction to project lombok. Change-Id: I1e5c90f2813f3e2b934df2841e97d1b81c74ee41 --- M .gitignore M pom.xml M src/main/java/org/wikimedia/search/extra/idhashmod/IdHashModQuery.java M src/main/java/org/wikimedia/search/extra/levenshtein/LevenshteinDistanceScoreBuilder.java A src/main/java/org/wikimedia/search/extra/lombok.config M src/main/java/org/wikimedia/search/extra/regex/AcceleratedSourceRegexQuery.java M src/main/java/org/wikimedia/search/extra/regex/SourceRegexQuery.java M src/main/java/org/wikimedia/search/extra/regex/UnacceleratedSourceRegexQuery.java M src/main/java/org/wikimedia/search/extra/regex/expression/AbstractCompositeExpression.java M src/main/java/org/wikimedia/search/extra/regex/expression/Leaf.java M src/main/java/org/wikimedia/search/extra/regex/ngram/NGramAutomaton.java M src/test/java/org/wikimedia/search/extra/regex/SourceRegexQueryRecheckTest.java 12 files changed, 44 insertions(+), 446 deletions(-) Approvals: DCausse: Looks good to me, approved jenkins-bot: Verified diff --git a/.gitignore b/.gitignore index 8e6397f..317b01f 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,5 @@ .settings .project +.idea +*.iml \ No newline at end of file diff --git a/pom.xml b/pom.xml index 80ea7da..9a5e3bd 100644 --- a/pom.xml +++ b/pom.xml @@ -294,6 +294,12 @@ <dependencies> <dependency> + <groupId>org.projectlombok</groupId> + <artifactId>lombok</artifactId> + <version>1.16.8</version> + <scope>provided</scope> + </dependency> + <dependency> <!-- Must come before Elasticsearch dependency. --> <groupId>org.apache.lucene</groupId> <artifactId>lucene-test-framework</artifactId> diff --git a/src/main/java/org/wikimedia/search/extra/idhashmod/IdHashModQuery.java b/src/main/java/org/wikimedia/search/extra/idhashmod/IdHashModQuery.java index 1c2e799..5c69f1b 100644 --- a/src/main/java/org/wikimedia/search/extra/idhashmod/IdHashModQuery.java +++ b/src/main/java/org/wikimedia/search/extra/idhashmod/IdHashModQuery.java @@ -3,6 +3,7 @@ import java.io.IOException; import java.util.Locale; +import lombok.EqualsAndHashCode; import org.apache.lucene.index.LeafReaderContext; import org.apache.lucene.search.ConstantScoreScorer; import org.apache.lucene.search.ConstantScoreWeight; @@ -39,6 +40,7 @@ * which is how you'd use this query anyway. On the other hand this is fast * enough. */ +@EqualsAndHashCode public class IdHashModQuery extends Query { private final IndexFieldData<?> uidFieldData; private final int mod; @@ -108,34 +110,4 @@ return "IdHashModQuery"; } - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + match; - result = prime * result + mod; - result = prime * result + ((uidFieldData == null) ? 0 : uidFieldData.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (!super.equals(obj)) - return false; - if (getClass() != obj.getClass()) - return false; - IdHashModQuery other = (IdHashModQuery) obj; - if (match != other.match) - return false; - if (mod != other.mod) - return false; - if (uidFieldData == null) { - if (other.uidFieldData != null) - return false; - } else if (!uidFieldData.equals(other.uidFieldData)) - return false; - return true; - } } diff --git a/src/main/java/org/wikimedia/search/extra/levenshtein/LevenshteinDistanceScoreBuilder.java b/src/main/java/org/wikimedia/search/extra/levenshtein/LevenshteinDistanceScoreBuilder.java index 66b0a06..ba50690 100644 --- a/src/main/java/org/wikimedia/search/extra/levenshtein/LevenshteinDistanceScoreBuilder.java +++ b/src/main/java/org/wikimedia/search/extra/levenshtein/LevenshteinDistanceScoreBuilder.java @@ -2,16 +2,19 @@ import java.io.IOException; +import lombok.Setter; +import lombok.experimental.Accessors; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.index.query.functionscore.ScoreFunctionBuilder; /** * Builds the levenshtein_distance_score score function. */ +@Accessors(chain = true, fluent = true) public class LevenshteinDistanceScoreBuilder extends ScoreFunctionBuilder { - private String field; - private String text; - private String missing; + @Setter private String field; + @Setter private String text; + @Setter private String missing; @Override public String getName() { @@ -36,18 +39,4 @@ builder.endObject(); } - public LevenshteinDistanceScoreBuilder field(String field) { - this.field = field; - return this; - } - - public LevenshteinDistanceScoreBuilder text(String text) { - this.text = text; - return this; - } - - public LevenshteinDistanceScoreBuilder missing(String missing) { - this.missing = missing; - return this; - } } \ No newline at end of file diff --git a/src/main/java/org/wikimedia/search/extra/lombok.config b/src/main/java/org/wikimedia/search/extra/lombok.config new file mode 100644 index 0000000..e572d96 --- /dev/null +++ b/src/main/java/org/wikimedia/search/extra/lombok.config @@ -0,0 +1 @@ +lombok.equalsAndHashCode.callSuper = call \ No newline at end of file diff --git a/src/main/java/org/wikimedia/search/extra/regex/AcceleratedSourceRegexQuery.java b/src/main/java/org/wikimedia/search/extra/regex/AcceleratedSourceRegexQuery.java index 78b7edc..88136e4 100644 --- a/src/main/java/org/wikimedia/search/extra/regex/AcceleratedSourceRegexQuery.java +++ b/src/main/java/org/wikimedia/search/extra/regex/AcceleratedSourceRegexQuery.java @@ -2,6 +2,7 @@ import java.io.IOException; +import lombok.EqualsAndHashCode; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.LeafReaderContext; import org.apache.lucene.search.ConstantScoreScorer; @@ -18,6 +19,7 @@ /** * Accelerated version of the source_regex query. */ +@EqualsAndHashCode class AcceleratedSourceRegexQuery extends UnacceleratedSourceRegexQuery { private final Query approximation; @@ -67,28 +69,4 @@ return "source_regex(accelerated):" + field; } - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ((approximation == null) ? 0 : approximation.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (!super.equals(obj)) - return false; - if (getClass() != obj.getClass()) - return false; - AcceleratedSourceRegexQuery other = (AcceleratedSourceRegexQuery) obj; - if (approximation == null) { - if (other.approximation != null) - return false; - } else if (!approximation.equals(other.approximation)) - return false; - return true; - } } diff --git a/src/main/java/org/wikimedia/search/extra/regex/SourceRegexQuery.java b/src/main/java/org/wikimedia/search/extra/regex/SourceRegexQuery.java index b512553..bcb9e9d 100644 --- a/src/main/java/org/wikimedia/search/extra/regex/SourceRegexQuery.java +++ b/src/main/java/org/wikimedia/search/extra/regex/SourceRegexQuery.java @@ -3,6 +3,8 @@ import java.io.IOException; import java.util.Locale; +import lombok.Data; +import lombok.EqualsAndHashCode; import org.apache.lucene.index.IndexReader; import org.apache.lucene.search.Query; import org.apache.lucene.search.TwoPhaseIterator; @@ -19,6 +21,7 @@ import org.wikimedia.search.extra.regex.ngram.NGramExtractor; import org.wikimedia.search.extra.util.FieldValues; +@EqualsAndHashCode public class SourceRegexQuery extends Query { private static final ESLogger log = ESLoggerFactory.getLogger(SourceRegexQuery.class.getPackage().getName()); private final String fieldPath; @@ -37,7 +40,7 @@ this.loader = loader; this.settings = settings; this.gramSize = gramSize; - if (!settings.getCaseSensitive() + if (!settings.isCaseSensitive() && !settings.getLocale().getLanguage().equals("ga") && !settings.getLocale().getLanguage().equals("tr")) { rechecker = new NonBacktrackingOnTheFlyCaseConvertingRechecker(regex, settings); @@ -52,7 +55,7 @@ if (ngramFieldPath == null) { // Don't bother expanding the regex if there isn't a field to check // it against. Its unlikely to resolve to all false anyway. - if (settings.getRejectUnaccelerated()) { + if (settings.isRejectUnaccelerated()) { throw new UnableToAccelerateRegexException(regex, gramSize, ngramFieldPath); } return new UnacceleratedSourceRegexQuery(rechecker, fieldPath, loader, settings); @@ -66,7 +69,7 @@ Expression<String> expression = new NGramExtractor(gramSize, settings.getMaxExpand(), settings.getMaxStatesTraced(), settings.getMaxNgramsExtracted()).extract(automaton).simplify(); if (expression.alwaysTrue()) { - if (settings.getRejectUnaccelerated()) { + if (settings.isRejectUnaccelerated()) { throw new UnableToAccelerateRegexException(regex, gramSize, ngramFieldPath); } return new UnacceleratedSourceRegexQuery(rechecker, fieldPath, loader, settings).rewrite(reader); @@ -121,6 +124,7 @@ * Faster for case insensitive queries than the NonBacktrackingRechecker but * wrong for Irish and Turkish. */ + @EqualsAndHashCode(exclude = "charRun") static class NonBacktrackingOnTheFlyCaseConvertingRechecker implements Rechecker { private final String regex; private final Settings settings; @@ -145,7 +149,7 @@ private ContainsCharacterRunAutomaton getCharRun() { if(charRun == null) { String regexString = regex; - if (!settings.getCaseSensitive()) { + if (!settings.isCaseSensitive()) { regexString = regexString.toLowerCase(settings.getLocale()); } Automaton automaton = regexToAutomaton(new RegExp(regexString, RegExp.ALL ^ RegExp.AUTOMATON), @@ -164,41 +168,12 @@ return getCharRun().getSize(); } - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((regex == null) ? 0 : regex.hashCode()); - result = prime * result + ((settings == null) ? 0 : settings.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - NonBacktrackingOnTheFlyCaseConvertingRechecker other = (NonBacktrackingOnTheFlyCaseConvertingRechecker) obj; - if (regex == null) { - if (other.regex != null) - return false; - } else if (!regex.equals(other.regex)) - return false; - if (settings == null) { - if (other.settings != null) - return false; - } else if (!settings.equals(other.settings)) - return false; - return true; - } } /** * Much much faster than SlowRechecker. */ + @EqualsAndHashCode(exclude = "charRun") static class NonBacktrackingRechecker implements Rechecker { private final String regex; private final Settings settings; @@ -213,7 +188,7 @@ @Override public boolean recheck(Iterable<String> values) { for (String value : values) { - if (!settings.getCaseSensitive()) { + if (!settings.isCaseSensitive()) { value = value.toLowerCase(settings.getLocale()); } if (getCharRun().contains(value)) { @@ -226,7 +201,7 @@ private ContainsCharacterRunAutomaton getCharRun() { if (charRun == null) { String regexString = regex; - if (!settings.getCaseSensitive()) { + if (!settings.isCaseSensitive()) { regexString = regexString.toLowerCase(settings.getLocale()); } Automaton automaton = regexToAutomaton(new RegExp(regexString, RegExp.ALL ^ RegExp.AUTOMATON), @@ -241,41 +216,12 @@ return getCharRun().getSize(); } - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((regex == null) ? 0 : regex.hashCode()); - result = prime * result + ((settings == null) ? 0 : settings.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - NonBacktrackingRechecker other = (NonBacktrackingRechecker) obj; - if (regex == null) { - if (other.regex != null) - return false; - } else if (!regex.equals(other.regex)) - return false; - if (settings == null) { - if (other.settings != null) - return false; - } else if (!settings.equals(other.settings)) - return false; - return true; - } } /** * Simplistic recheck implemetation which is more obviously correct. */ + @EqualsAndHashCode(exclude = "charRun") static class SlowRechecker implements Rechecker { private final String regex; private final Settings settings; @@ -294,7 +240,7 @@ @Override public boolean recheck(Iterable<String> values) { for (String value : values) { - if (!settings.getCaseSensitive()) { + if (!settings.isCaseSensitive()) { value = value.toLowerCase(settings.getLocale()); } if (getCharRun().run(value)) { @@ -307,7 +253,7 @@ private CharacterRunAutomaton getCharRun() { if (charRun == null) { String regexString = regex; - if (!settings.getCaseSensitive()) { + if (!settings.isCaseSensitive()) { regexString = regexString.toLowerCase(settings.getLocale()); } Automaton automaton = regexToAutomaton(new RegExp(".*" + regexString + ".*", RegExp.ALL ^ RegExp.AUTOMATON), @@ -322,36 +268,6 @@ return getCharRun().getSize(); } - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((regex == null) ? 0 : regex.hashCode()); - result = prime * result + ((settings == null) ? 0 : settings.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - SlowRechecker other = (SlowRechecker) obj; - if (regex == null) { - if (other.regex != null) - return false; - } else if (!regex.equals(other.regex)) - return false; - if (settings == null) { - if (other.settings != null) - return false; - } else if (!settings.equals(other.settings)) - return false; - return true; - } } @Override @@ -364,58 +280,7 @@ return b.toString(); } - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((fieldPath == null) ? 0 : fieldPath.hashCode()); - result = prime * result + gramSize; - result = prime * result + ((loader == null) ? 0 : loader.hashCode()); - result = prime * result + ((ngramFieldPath == null) ? 0 : ngramFieldPath.hashCode()); - result = prime * result + ((regex == null) ? 0 : regex.hashCode()); - result = prime * result + ((settings == null) ? 0 : settings.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - SourceRegexQuery other = (SourceRegexQuery) obj; - if (fieldPath == null) { - if (other.fieldPath != null) - return false; - } else if (!fieldPath.equals(other.fieldPath)) - return false; - if (gramSize != other.gramSize) - return false; - if (loader == null) { - if (other.loader != null) - return false; - } else if (!loader.equals(other.loader)) - return false; - if (ngramFieldPath == null) { - if (other.ngramFieldPath != null) - return false; - } else if (!ngramFieldPath.equals(other.ngramFieldPath)) - return false; - if (regex == null) { - if (other.regex != null) - return false; - } else if (!regex.equals(other.regex)) - return false; - if (settings == null) { - if (other.settings != null) - return false; - } else if (!settings.equals(other.settings)) - return false; - return true; - } - + @Data public static class Settings { private int maxExpand = 4; private int maxStatesTraced = 10000; @@ -424,125 +289,11 @@ /** * @deprecated use a generic time limiting collector */ + @Deprecated private int maxInspect = Integer.MAX_VALUE; private boolean caseSensitive = false; private Locale locale = Locale.ROOT; private boolean rejectUnaccelerated = false; - public int getMaxExpand() { - return maxExpand; - } - - public void setMaxExpand(int maxExpand) { - this.maxExpand = maxExpand; - } - - public int getMaxStatesTraced() { - return maxStatesTraced; - } - - public void setMaxStatesTraced(int maxStatesTraced) { - this.maxStatesTraced = maxStatesTraced; - } - - public int getMaxDeterminizedStates() { - return maxDeterminizedStates; - } - - public void setMaxDeterminizedStates(int maxDeterminizedStates) { - this.maxDeterminizedStates = maxDeterminizedStates; - } - - public int getMaxNgramsExtracted() { - return maxNgramsExtracted; - } - - public void setMaxNgramsExtracted(int maxNgramsExtracted) { - this.maxNgramsExtracted = maxNgramsExtracted; - } - - /** - * @deprecated use a generic time limiting collector - */ - public int getMaxInspect() { - return maxInspect; - } - - /** - * @deprecated use a generic time limiting collector - */ - public void setMaxInspect(int maxInspect) { - this.maxInspect = maxInspect; - } - - public boolean getCaseSensitive() { - return caseSensitive; - } - - public void setCaseSensitive(boolean caseSensitive) { - this.caseSensitive = caseSensitive; - } - - public Locale getLocale() { - return locale; - } - - public void setLocale(Locale locale) { - this.locale = locale; - } - - public boolean getRejectUnaccelerated() { - return rejectUnaccelerated; - } - - public void setRejectUnaccelerated(boolean rejectUnaccelerated) { - this.rejectUnaccelerated = rejectUnaccelerated; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + (caseSensitive ? 1231 : 1237); - result = prime * result + ((locale == null) ? 0 : locale.hashCode()); - result = prime * result + maxDeterminizedStates; - result = prime * result + maxExpand; - result = prime * result + maxInspect; - result = prime * result + maxNgramsExtracted; - result = prime * result + maxStatesTraced; - result = prime * result + (rejectUnaccelerated ? 1231 : 1237); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - Settings other = (Settings) obj; - if (caseSensitive != other.caseSensitive) - return false; - if (locale == null) { - if (other.locale != null) - return false; - } else if (!locale.equals(other.locale)) - return false; - if (maxDeterminizedStates != other.maxDeterminizedStates) - return false; - if (maxExpand != other.maxExpand) - return false; - if (maxInspect != other.maxInspect) - return false; - if (maxNgramsExtracted != other.maxNgramsExtracted) - return false; - if (maxStatesTraced != other.maxStatesTraced) - return false; - if (rejectUnaccelerated != other.rejectUnaccelerated) - return false; - return true; - } } } diff --git a/src/main/java/org/wikimedia/search/extra/regex/UnacceleratedSourceRegexQuery.java b/src/main/java/org/wikimedia/search/extra/regex/UnacceleratedSourceRegexQuery.java index 52e2519..1728605 100644 --- a/src/main/java/org/wikimedia/search/extra/regex/UnacceleratedSourceRegexQuery.java +++ b/src/main/java/org/wikimedia/search/extra/regex/UnacceleratedSourceRegexQuery.java @@ -3,6 +3,7 @@ import java.io.IOException; import java.util.List; +import lombok.EqualsAndHashCode; import org.apache.lucene.index.LeafReaderContext; import org.apache.lucene.search.ConstantScoreScorer; import org.apache.lucene.search.ConstantScoreWeight; @@ -22,6 +23,7 @@ * Unaccelerated source_regex query. * It will scan all the docs in the index. */ +@EqualsAndHashCode class UnacceleratedSourceRegexQuery extends Query { protected final Rechecker rechecker; protected final String fieldPath; @@ -102,46 +104,4 @@ } } - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ((fieldPath == null) ? 0 : fieldPath.hashCode()); - result = prime * result + ((loader == null) ? 0 : loader.hashCode()); - result = prime * result + ((rechecker == null) ? 0 : rechecker.hashCode()); - result = prime * result + ((settings == null) ? 0 : settings.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (!super.equals(obj)) - return false; - if (getClass() != obj.getClass()) - return false; - UnacceleratedSourceRegexQuery other = (UnacceleratedSourceRegexQuery) obj; - if (fieldPath == null) { - if (other.fieldPath != null) - return false; - } else if (!fieldPath.equals(other.fieldPath)) - return false; - if (loader == null) { - if (other.loader != null) - return false; - } else if (!loader.equals(other.loader)) - return false; - if (rechecker == null) { - if (other.rechecker != null) - return false; - } else if (!rechecker.equals(other.rechecker)) - return false; - if (settings == null) { - if (other.settings != null) - return false; - } else if (!settings.equals(other.settings)) - return false; - return true; - } } diff --git a/src/main/java/org/wikimedia/search/extra/regex/expression/AbstractCompositeExpression.java b/src/main/java/org/wikimedia/search/extra/regex/expression/AbstractCompositeExpression.java index 397903f..9a74d54 100644 --- a/src/main/java/org/wikimedia/search/extra/regex/expression/AbstractCompositeExpression.java +++ b/src/main/java/org/wikimedia/search/extra/regex/expression/AbstractCompositeExpression.java @@ -8,11 +8,13 @@ import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; +import lombok.EqualsAndHashCode; /** * Abstract parent for composite expressions like And and Or. */ +@EqualsAndHashCode(exclude = { "simplified", "toString" }) public abstract class AbstractCompositeExpression<T> implements Expression<T> { private static final int MAX_COMPONENT_STRING_LENGTH = 1000; private static final int MAX_COMPONENTS_SIZE_FOR_TO_STRING = 10; @@ -261,21 +263,4 @@ return toString; } - @Override - public int hashCode() { - return components.hashCode(); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - @SuppressWarnings("rawtypes") - AbstractCompositeExpression other = (AbstractCompositeExpression) obj; - return components.equals(other.components); - } } diff --git a/src/main/java/org/wikimedia/search/extra/regex/expression/Leaf.java b/src/main/java/org/wikimedia/search/extra/regex/expression/Leaf.java index 7a8b9a0..3c42f46 100644 --- a/src/main/java/org/wikimedia/search/extra/regex/expression/Leaf.java +++ b/src/main/java/org/wikimedia/search/extra/regex/expression/Leaf.java @@ -2,10 +2,12 @@ import static com.google.common.base.Preconditions.*; import com.google.common.collect.ImmutableSet; +import lombok.EqualsAndHashCode; /** * A leaf expression. */ +@EqualsAndHashCode public final class Leaf<T> implements Expression<T> { @SafeVarargs public static final <T> ImmutableSet<Expression<T>> leaves(T... ts) { @@ -17,7 +19,6 @@ } private final T t; - private int hashCode; public Leaf(T t) { this.t = checkNotNull(t); @@ -52,24 +53,4 @@ return transformer.leaf(t); } - @Override - public int hashCode() { - if (hashCode == 0) { - hashCode = t.hashCode(); - } - return hashCode; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - @SuppressWarnings("rawtypes") - Leaf other = (Leaf) obj; - return t.equals(other.t); - } } diff --git a/src/main/java/org/wikimedia/search/extra/regex/ngram/NGramAutomaton.java b/src/main/java/org/wikimedia/search/extra/regex/ngram/NGramAutomaton.java index 437da96..f66c687 100644 --- a/src/main/java/org/wikimedia/search/extra/regex/ngram/NGramAutomaton.java +++ b/src/main/java/org/wikimedia/search/extra/regex/ngram/NGramAutomaton.java @@ -6,6 +6,7 @@ import java.util.List; import java.util.Map; +import lombok.EqualsAndHashCode; import org.apache.lucene.util.automaton.Automaton; import org.apache.lucene.util.automaton.Transition; import org.wikimedia.search.extra.regex.expression.And; @@ -222,6 +223,7 @@ * State in the ngram graph. Equals and hashcode only use the sourceState * and prefix. */ + @EqualsAndHashCode(of = { "prefix", "sourceState" }) private static class NGramState implements ExpressionSource<String> { /** * We use the 0 char to stand in for code points we can't match. @@ -298,35 +300,6 @@ } } return expression; - } - - // Equals and hashcode from Eclipse. - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((prefix == null) ? 0 : prefix.hashCode()); - result = prime * result + sourceState; - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - NGramState other = (NGramState) obj; - if (prefix == null) { - if (other.prefix != null) - return false; - } else if (!prefix.equals(other.prefix)) - return false; - if (sourceState != other.sourceState) - return false; - return true; } } diff --git a/src/test/java/org/wikimedia/search/extra/regex/SourceRegexQueryRecheckTest.java b/src/test/java/org/wikimedia/search/extra/regex/SourceRegexQueryRecheckTest.java index 3dcedcb..a776c27 100644 --- a/src/test/java/org/wikimedia/search/extra/regex/SourceRegexQueryRecheckTest.java +++ b/src/test/java/org/wikimedia/search/extra/regex/SourceRegexQueryRecheckTest.java @@ -72,7 +72,7 @@ long slow = manyTestCase(new SlowRechecker(regex, settings), "slow", name, settings, times, regex); long nonBacktracking = manyTestCase(new NonBacktrackingRechecker(regex, settings), "non backtracking", name, settings, times, regex); assertTrue("Nonbacktracking is faster than slow", slow > nonBacktracking); - if (!settings.getCaseSensitive()) { + if (!settings.isCaseSensitive()) { long nonBacktrackingCaseConverting = manyTestCase(new NonBacktrackingOnTheFlyCaseConvertingRechecker(regex, settings), "case converting", name, settings, times, regex); if (!matchIsNearTheEnd) { -- To view, visit https://gerrit.wikimedia.org/r/283211 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I1e5c90f2813f3e2b934df2841e97d1b81c74ee41 Gerrit-PatchSet: 11 Gerrit-Project: search/extra Gerrit-Branch: master Gerrit-Owner: Gehel <[email protected]> Gerrit-Reviewer: DCausse <[email protected]> Gerrit-Reviewer: EBernhardson <[email protected]> Gerrit-Reviewer: Gehel <[email protected]> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
