Implement equals and hashCode on ranking and partition functions
Esse commit está contido em:
@@ -165,4 +165,38 @@ public class FunctionImpl implements RankingFunction, PartitionFunction, SimpleF
|
||||
}
|
||||
return super.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 5;
|
||||
hash = 47 * hash + (this.column != null ? this.column.hashCode() : 0);
|
||||
hash = 47 * hash + (this.transformer != null ? this.transformer.hashCode() : 0);
|
||||
hash = 47 * hash + (this.partition != null ? this.partition.hashCode() : 0);
|
||||
hash = 47 * hash + (this.ranking != null ? this.ranking.hashCode() : 0);
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final FunctionImpl other = (FunctionImpl) obj;
|
||||
if (this.column != other.column && (this.column == null || !this.column.equals(other.column))) {
|
||||
return false;
|
||||
}
|
||||
if (this.transformer != other.transformer && (this.transformer == null || !this.transformer.equals(other.transformer))) {
|
||||
return false;
|
||||
}
|
||||
if (this.partition != other.partition && (this.partition == null || !this.partition.equals(other.partition))) {
|
||||
return false;
|
||||
}
|
||||
if (this.ranking != other.ranking && (this.ranking == null || !this.ranking.equals(other.ranking))) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,4 +104,26 @@ public class PartitionImpl implements Partition {
|
||||
public Column getColumn() {
|
||||
return column;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 3;
|
||||
hash = 23 * hash + (this.column != null ? this.column.hashCode() : 0);
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final PartitionImpl other = (PartitionImpl) obj;
|
||||
if (this.column != other.column && (this.column == null || !this.column.equals(other.column))) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ public class RankingImpl implements Ranking {
|
||||
|
||||
@Override
|
||||
public Number getMaxValue() {
|
||||
return index.getMinValue(column);
|
||||
return index.getMaxValue(column);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -87,4 +87,26 @@ public class RankingImpl implements Ranking {
|
||||
float normalizedValue = (float) (value.doubleValue() - getMinValue().doubleValue()) / (float) (getMaxValue().doubleValue() - getMinValue().doubleValue());
|
||||
return interpolator.interpolate(normalizedValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 3;
|
||||
hash = 67 * hash + (this.column != null ? this.column.hashCode() : 0);
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final RankingImpl other = (RankingImpl) obj;
|
||||
if (this.column != other.column && (this.column == null || !this.column.equals(other.column))) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário