changed equals/hashCode implementation

This commit is contained in:
navis.ryu 2015-11-02 17:21:35 +09:00
parent 69c86716d6
commit e03fc2032f
2 changed files with 12 additions and 10 deletions

View File

@ -19,6 +19,7 @@ package io.druid.query.search.search;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.base.Objects;
import com.metamx.common.StringUtils;
import java.nio.ByteBuffer;
@ -109,16 +110,16 @@ public class ContainsSearchQuerySpec implements SearchQuerySpec
return false;
}
if (value != null ? !value.equals(that.value) : that.value != null) {
return false;
if (value == null && that.value == null) {
return true;
}
return true;
return value != null && value.equals(that.value);
}
@Override
public int hashCode()
{
return value != null ? value.hashCode() : 0;
return Objects.hashCode(value) + (caseSensitive ? (byte) 1 : 0);
}
}

View File

@ -22,9 +22,10 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.metamx.common.StringUtils;
import java.nio.ByteBuffer;
import java.util.HashSet;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;
/**
*/
@ -53,7 +54,7 @@ public class FragmentSearchQuerySpec implements SearchQuerySpec
{
this.values = values;
this.caseSensitive = caseSensitive;
Set<String> set = new HashSet();
Set<String> set = new TreeSet();
if (values != null) {
for (String value : values) {
set.add(value);
@ -154,16 +155,16 @@ public class FragmentSearchQuerySpec implements SearchQuerySpec
return false;
}
if (values != null ? !values.equals(that.values) : that.values != null) {
return false;
if (values == null && that.values == null) {
return true;
}
return true;
return values != null && Arrays.equals(target, that.target);
}
@Override
public int hashCode()
{
return values != null ? values.hashCode() : 0;
return Arrays.hashCode(target) + (caseSensitive ? (byte) 1 : 0);
}
}