Backport: Refactor aggregation base classes to remove doEquals() and doHashCode() (#43363)

This PR is a backport a of #43214 from v8.0.0

A number of the aggregation base classes have an abstract doEquals() and doHashCode() (e.g. InternalAggregation.java, AbstractPipelineAggregationBuilder.java).

Theoretically this is so the sub-classes can add to the equals/hashCode and don't need to worry about calling super.equals(). In practice, it's mostly just confusing/inconsistent. And if there are more than two levels, we end up with situations like InternalMappedSignificantTerms which has to call super.doEquals() which defeats the point of having these overridable methods.

This PR removes the do versions and just use equals/hashCode ensuring the super when necessary.
This commit is contained in:
Christos Soulios 2019-06-19 22:31:06 +03:00 committed by GitHub
parent be42b2c70c
commit d1637ca476
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
106 changed files with 652 additions and 694 deletions

View File

@ -256,12 +256,16 @@ public class InternalMatrixStats extends InternalAggregation implements MatrixSt
} }
@Override @Override
protected int doHashCode() { public int hashCode() {
return Objects.hash(stats, results); return Objects.hash(super.hashCode(), stats, results);
} }
@Override @Override
protected boolean doEquals(Object obj) { public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
if (super.equals(obj) == false) return false;
InternalMatrixStats other = (InternalMatrixStats) obj; InternalMatrixStats other = (InternalMatrixStats) obj;
return Objects.equals(this.stats, other.stats) && return Objects.equals(this.stats, other.stats) &&
Objects.equals(this.results, other.results); Objects.equals(this.results, other.results);

View File

@ -91,16 +91,6 @@ public class MatrixStatsAggregationBuilder
return builder; return builder;
} }
@Override
protected int innerHashCode() {
return 0;
}
@Override
protected boolean innerEquals(Object obj) {
return true;
}
@Override @Override
public String getType() { public String getType() {
return NAME; return NAME;

View File

@ -354,30 +354,21 @@ public abstract class ArrayValuesSourceAggregationBuilder<VS extends ValuesSourc
protected abstract XContentBuilder doXContentBody(XContentBuilder builder, Params params) throws IOException; protected abstract XContentBuilder doXContentBody(XContentBuilder builder, Params params) throws IOException;
@Override @Override
protected final int doHashCode() { public int hashCode() {
return Objects.hash(fields, format, missing, targetValueType, valueType, valuesSourceType, return Objects.hash(super.hashCode(), fields, format, missing, targetValueType, valueType, valuesSourceType);
innerHashCode());
} }
protected abstract int innerHashCode();
@Override @Override
protected final boolean doEquals(Object obj) { public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
if (super.equals(obj) == false) return false;
ArrayValuesSourceAggregationBuilder<?, ?> other = (ArrayValuesSourceAggregationBuilder<?, ?>) obj; ArrayValuesSourceAggregationBuilder<?, ?> other = (ArrayValuesSourceAggregationBuilder<?, ?>) obj;
if (!Objects.equals(fields, other.fields)) return Objects.equals(fields, other.fields)
return false; && Objects.equals(format, other.format)
if (!Objects.equals(format, other.format)) && Objects.equals(missing, other.missing)
return false; && Objects.equals(targetValueType, other.targetValueType)
if (!Objects.equals(missing, other.missing)) && Objects.equals(valueType, other.valueType)
return false; && Objects.equals(valuesSourceType, other.valuesSourceType);
if (!Objects.equals(targetValueType, other.targetValueType))
return false;
if (!Objects.equals(valueType, other.valueType))
return false;
if (!Objects.equals(valuesSourceType, other.valuesSourceType))
return false;
return innerEquals(obj);
} }
protected abstract boolean innerEquals(Object obj);
} }

View File

@ -159,12 +159,15 @@ public class ChildrenAggregationBuilder
} }
@Override @Override
protected int innerHashCode() { public int hashCode() {
return Objects.hash(childType); return Objects.hash(super.hashCode(), childType);
} }
@Override @Override
protected boolean innerEquals(Object obj) { public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
if (super.equals(obj) == false) return false;
ChildrenAggregationBuilder other = (ChildrenAggregationBuilder) obj; ChildrenAggregationBuilder other = (ChildrenAggregationBuilder) obj;
return Objects.equals(childType, other.childType); return Objects.equals(childType, other.childType);
} }

View File

@ -159,12 +159,15 @@ public class ParentAggregationBuilder
} }
@Override @Override
protected int innerHashCode() { public int hashCode() {
return Objects.hash(childType); return Objects.hash(super.hashCode(), childType);
} }
@Override @Override
protected boolean innerEquals(Object obj) { public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
if (super.equals(obj) == false) return false;
ParentAggregationBuilder other = (ParentAggregationBuilder) obj; ParentAggregationBuilder other = (ParentAggregationBuilder) obj;
return Objects.equals(childType, other.childType); return Objects.equals(childType, other.childType);
} }

View File

@ -164,28 +164,17 @@ public abstract class AbstractAggregationBuilder<AB extends AbstractAggregationB
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(factoriesBuilder, metaData, name, doHashCode()); return Objects.hash(factoriesBuilder, metaData, name);
} }
protected abstract int doHashCode();
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (obj == null) if (this == obj) return true;
return false; if (obj == null || getClass() != obj.getClass()) return false;
if (getClass() != obj.getClass())
return false;
@SuppressWarnings("unchecked")
AbstractAggregationBuilder<AB> other = (AbstractAggregationBuilder<AB>) obj; AbstractAggregationBuilder<AB> other = (AbstractAggregationBuilder<AB>) obj;
if (!Objects.equals(name, other.name))
return false; return Objects.equals(name, other.name)
if (!Objects.equals(metaData, other.metaData)) && Objects.equals(metaData, other.metaData)
return false; && Objects.equals(factoriesBuilder, other.factoriesBuilder);
if (!Objects.equals(factoriesBuilder, other.factoriesBuilder))
return false;
return doEquals(obj);
} }
protected abstract boolean doEquals(Object obj);
} }

View File

@ -218,40 +218,22 @@ public abstract class InternalAggregation implements Aggregation, NamedWriteable
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(name, metaData, pipelineAggregators, doHashCode()); return Objects.hash(name, metaData, pipelineAggregators);
} }
/**
* Opportunity for subclasses to the {@link #hashCode()} for this
* class.
**/
protected abstract int doHashCode();
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (obj == null) { if (obj == null || getClass() != obj.getClass()) {
return false;
}
if (obj.getClass() != getClass()) {
return false; return false;
} }
if (obj == this) { return true; }
InternalAggregation other = (InternalAggregation) obj; InternalAggregation other = (InternalAggregation) obj;
return Objects.equals(name, other.name) && return Objects.equals(name, other.name) &&
Objects.equals(pipelineAggregators, other.pipelineAggregators) && Objects.equals(pipelineAggregators, other.pipelineAggregators) &&
Objects.equals(metaData, other.metaData) && Objects.equals(metaData, other.metaData);
doEquals(obj);
} }
/**
* Opportunity for subclasses to add criteria to the {@link #equals(Object)}
* method for this class.
*
* This method can safely cast <code>obj</code> to the subclass since the
* {@link #equals(Object)} method checks that <code>obj</code> is the same
* class as <code>this</code>
*/
protected abstract boolean doEquals(Object obj);
@Override @Override
public String toString() { public String toString() {
return Strings.toString(this); return Strings.toString(this);

View File

@ -137,14 +137,18 @@ public abstract class InternalSingleBucketAggregation extends InternalAggregatio
} }
@Override @Override
protected boolean doEquals(Object obj) { public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
if (super.equals(obj) == false) return false;
InternalSingleBucketAggregation other = (InternalSingleBucketAggregation) obj; InternalSingleBucketAggregation other = (InternalSingleBucketAggregation) obj;
return Objects.equals(docCount, other.docCount) && return Objects.equals(docCount, other.docCount) &&
Objects.equals(aggregations, other.aggregations); Objects.equals(aggregations, other.aggregations);
} }
@Override @Override
protected int doHashCode() { public int hashCode() {
return Objects.hash(docCount, aggregations); return Objects.hash(super.hashCode(), docCount, aggregations);
} }
} }

View File

@ -230,12 +230,15 @@ public class AdjacencyMatrixAggregationBuilder extends AbstractAggregationBuilde
} }
@Override @Override
protected int doHashCode() { public int hashCode() {
return Objects.hash(filters, separator); return Objects.hash(super.hashCode(), filters, separator);
} }
@Override @Override
protected boolean doEquals(Object obj) { public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
if (super.equals(obj) == false) return false;
AdjacencyMatrixAggregationBuilder other = (AdjacencyMatrixAggregationBuilder) obj; AdjacencyMatrixAggregationBuilder other = (AdjacencyMatrixAggregationBuilder) obj;
return Objects.equals(filters, other.filters) && Objects.equals(separator, other.separator); return Objects.equals(filters, other.filters) && Objects.equals(separator, other.separator);
} }

View File

@ -239,12 +239,16 @@ public class InternalAdjacencyMatrix
} }
@Override @Override
protected int doHashCode() { public int hashCode() {
return Objects.hash(buckets); return Objects.hash(super.hashCode(), buckets);
} }
@Override @Override
protected boolean doEquals(Object obj) { public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
if (super.equals(obj) == false) return false;
InternalAdjacencyMatrix that = (InternalAdjacencyMatrix) obj; InternalAdjacencyMatrix that = (InternalAdjacencyMatrix) obj;
return Objects.equals(buckets, that.buckets); return Objects.equals(buckets, that.buckets);
} }

View File

@ -256,12 +256,15 @@ public class CompositeAggregationBuilder extends AbstractAggregationBuilder<Comp
} }
@Override @Override
protected int doHashCode() { public int hashCode() {
return Objects.hash(sources, size, after); return Objects.hash(super.hashCode(), sources, size, after);
} }
@Override @Override
protected boolean doEquals(Object obj) { public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
if (super.equals(obj) == false) return false;
CompositeAggregationBuilder other = (CompositeAggregationBuilder) obj; CompositeAggregationBuilder other = (CompositeAggregationBuilder) obj;
return size == other.size && return size == other.size &&
Objects.equals(sources, other.sources) && Objects.equals(sources, other.sources) &&

View File

@ -138,12 +138,10 @@ public abstract class CompositeValuesSourceBuilder<AB extends CompositeValuesSou
} }
@Override @Override
public final int hashCode() { public int hashCode() {
return Objects.hash(field, missingBucket, script, valueType, order, format, innerHashCode()); return Objects.hash(field, missingBucket, script, valueType, order, format);
} }
protected abstract int innerHashCode();
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) return true; if (this == o) return true;
@ -156,12 +154,9 @@ public abstract class CompositeValuesSourceBuilder<AB extends CompositeValuesSou
Objects.equals(valueType, that.valueType()) && Objects.equals(valueType, that.valueType()) &&
Objects.equals(missingBucket, that.missingBucket()) && Objects.equals(missingBucket, that.missingBucket()) &&
Objects.equals(order, that.order()) && Objects.equals(order, that.order()) &&
Objects.equals(format, that.format()) && Objects.equals(format, that.format());
innerEquals(that);
} }
protected abstract boolean innerEquals(AB builder);
public String name() { public String name() {
return name; return name;
} }

View File

@ -97,12 +97,16 @@ public class DateHistogramValuesSourceBuilder
} }
@Override @Override
protected int innerHashCode() { public int hashCode() {
return Objects.hash(dateHistogramInterval, timeZone); return Objects.hash(super.hashCode(), dateHistogramInterval, timeZone);
} }
@Override @Override
protected boolean innerEquals(DateHistogramValuesSourceBuilder other) { public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
if (super.equals(obj) == false) return false;
DateHistogramValuesSourceBuilder other = (DateHistogramValuesSourceBuilder) obj;
return Objects.equals(dateHistogramInterval, other.dateHistogramInterval) return Objects.equals(dateHistogramInterval, other.dateHistogramInterval)
&& Objects.equals(timeZone, other.timeZone); && Objects.equals(timeZone, other.timeZone);
} }

View File

@ -73,12 +73,16 @@ public class HistogramValuesSourceBuilder extends CompositeValuesSourceBuilder<H
} }
@Override @Override
protected int innerHashCode() { public int hashCode() {
return Objects.hash(interval); return Objects.hash(super.hashCode(), interval);
} }
@Override @Override
protected boolean innerEquals(HistogramValuesSourceBuilder other) { public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
if (super.equals(obj) == false) return false;
HistogramValuesSourceBuilder other = (HistogramValuesSourceBuilder) obj;
return Objects.equals(interval, other.interval); return Objects.equals(interval, other.interval);
} }

View File

@ -195,7 +195,11 @@ public class InternalComposite
} }
@Override @Override
protected boolean doEquals(Object obj) { public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
if (super.equals(obj) == false) return false;
InternalComposite that = (InternalComposite) obj; InternalComposite that = (InternalComposite) obj;
return Objects.equals(size, that.size) && return Objects.equals(size, that.size) &&
Objects.equals(buckets, that.buckets) && Objects.equals(buckets, that.buckets) &&
@ -204,8 +208,8 @@ public class InternalComposite
} }
@Override @Override
protected int doHashCode() { public int hashCode() {
return Objects.hash(size, buckets, afterKey, Arrays.hashCode(reverseMuls)); return Objects.hash(super.hashCode(), size, buckets, afterKey, Arrays.hashCode(reverseMuls));
} }
private static class BucketIterator implements Comparable<BucketIterator> { private static class BucketIterator implements Comparable<BucketIterator> {

View File

@ -64,16 +64,6 @@ public class TermsValuesSourceBuilder extends CompositeValuesSourceBuilder<Terms
@Override @Override
protected void doXContentBody(XContentBuilder builder, Params params) throws IOException {} protected void doXContentBody(XContentBuilder builder, Params params) throws IOException {}
@Override
protected int innerHashCode() {
return 0;
}
@Override
protected boolean innerEquals(TermsValuesSourceBuilder builder) {
return true;
}
@Override @Override
public String type() { public String type() {
return TYPE; return TYPE;

View File

@ -112,12 +112,15 @@ public class FilterAggregationBuilder extends AbstractAggregationBuilder<FilterA
} }
@Override @Override
protected int doHashCode() { public int hashCode() {
return Objects.hash(filter); return Objects.hash(super.hashCode(), filter);
} }
@Override @Override
protected boolean doEquals(Object obj) { public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
if (super.equals(obj) == false) return false;
FilterAggregationBuilder other = (FilterAggregationBuilder) obj; FilterAggregationBuilder other = (FilterAggregationBuilder) obj;
return Objects.equals(filter, other.filter); return Objects.equals(filter, other.filter);
} }

View File

@ -331,12 +331,15 @@ public class FiltersAggregationBuilder extends AbstractAggregationBuilder<Filter
} }
@Override @Override
protected int doHashCode() { public int hashCode() {
return Objects.hash(filters, keyed, otherBucket, otherBucketKey); return Objects.hash(super.hashCode(), filters, keyed, otherBucket, otherBucketKey);
} }
@Override @Override
protected boolean doEquals(Object obj) { public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
if (super.equals(obj) == false) return false;
FiltersAggregationBuilder other = (FiltersAggregationBuilder) obj; FiltersAggregationBuilder other = (FiltersAggregationBuilder) obj;
return Objects.equals(filters, other.filters) return Objects.equals(filters, other.filters)
&& Objects.equals(keyed, other.keyed) && Objects.equals(keyed, other.keyed)

View File

@ -251,12 +251,16 @@ public class InternalFilters extends InternalMultiBucketAggregation<InternalFilt
} }
@Override @Override
protected int doHashCode() { public int hashCode() {
return Objects.hash(buckets, keyed); return Objects.hash(super.hashCode(), buckets, keyed);
} }
@Override @Override
protected boolean doEquals(Object obj) { public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
if (super.equals(obj) == false) return false;
InternalFilters that = (InternalFilters) obj; InternalFilters that = (InternalFilters) obj;
return Objects.equals(buckets, that.buckets) return Objects.equals(buckets, that.buckets)
&& Objects.equals(keyed, that.keyed); && Objects.equals(keyed, that.keyed);

View File

@ -180,22 +180,18 @@ public abstract class GeoGridAggregationBuilder extends ValuesSourceAggregationB
} }
@Override @Override
protected boolean innerEquals(Object obj) { public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
if (super.equals(obj) == false) return false;
GeoGridAggregationBuilder other = (GeoGridAggregationBuilder) obj; GeoGridAggregationBuilder other = (GeoGridAggregationBuilder) obj;
if (precision != other.precision) { return precision == other.precision
return false; && requiredSize == other.requiredSize
} && shardSize == other.shardSize;
if (requiredSize != other.requiredSize) {
return false;
}
if (shardSize != other.shardSize) {
return false;
}
return true;
} }
@Override @Override
protected int innerHashCode() { public int hashCode() {
return Objects.hash(precision, requiredSize, shardSize); return Objects.hash(super.hashCode(), precision, requiredSize, shardSize);
} }
} }

View File

@ -133,15 +133,19 @@ public abstract class InternalGeoGrid<B extends InternalGeoGridBucket>
} }
@Override @Override
protected int doHashCode() { public int hashCode() {
return Objects.hash(requiredSize, buckets); return Objects.hash(super.hashCode(), requiredSize, buckets);
} }
@Override @Override
protected boolean doEquals(Object obj) { public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
if (super.equals(obj) == false) return false;
InternalGeoGrid other = (InternalGeoGrid) obj; InternalGeoGrid other = (InternalGeoGrid) obj;
return Objects.equals(requiredSize, other.requiredSize) && return Objects.equals(requiredSize, other.requiredSize)
Objects.equals(buckets, other.buckets); && Objects.equals(buckets, other.buckets);
} }
} }

View File

@ -78,16 +78,6 @@ public class GlobalAggregationBuilder extends AbstractAggregationBuilder<GlobalA
return new GlobalAggregationBuilder(aggregationName); return new GlobalAggregationBuilder(aggregationName);
} }
@Override
protected boolean doEquals(Object obj) {
return true;
}
@Override
protected int doHashCode() {
return 0;
}
@Override @Override
public String getType() { public String getType() {
return NAME; return NAME;

View File

@ -221,12 +221,15 @@ public class AutoDateHistogramAggregationBuilder
} }
@Override @Override
protected int innerHashCode() { public int hashCode() {
return Objects.hash(numBuckets, minimumIntervalExpression); return Objects.hash(super.hashCode(), numBuckets, minimumIntervalExpression);
} }
@Override @Override
protected boolean innerEquals(Object obj) { public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
if (super.equals(obj) == false) return false;
AutoDateHistogramAggregationBuilder other = (AutoDateHistogramAggregationBuilder) obj; AutoDateHistogramAggregationBuilder other = (AutoDateHistogramAggregationBuilder) obj;
return Objects.equals(numBuckets, other.numBuckets) && Objects.equals(minimumIntervalExpression, other.minimumIntervalExpression); return Objects.equals(numBuckets, other.numBuckets) && Objects.equals(minimumIntervalExpression, other.minimumIntervalExpression);
} }

View File

@ -506,12 +506,15 @@ public class DateHistogramAggregationBuilder extends ValuesSourceAggregationBuil
} }
@Override @Override
protected int innerHashCode() { public int hashCode() {
return Objects.hash(order, keyed, minDocCount, dateHistogramInterval, minDocCount, extendedBounds); return Objects.hash(super.hashCode(), order, keyed, minDocCount, dateHistogramInterval, minDocCount, extendedBounds);
} }
@Override @Override
protected boolean innerEquals(Object obj) { public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
if (super.equals(obj) == false) return false;
DateHistogramAggregationBuilder other = (DateHistogramAggregationBuilder) obj; DateHistogramAggregationBuilder other = (DateHistogramAggregationBuilder) obj;
return Objects.equals(order, other.order) return Objects.equals(order, other.order)
&& Objects.equals(keyed, other.keyed) && Objects.equals(keyed, other.keyed)

View File

@ -302,19 +302,22 @@ public class HistogramAggregationBuilder extends ValuesSourceAggregationBuilder<
} }
@Override @Override
protected int innerHashCode() { public int hashCode() {
return Objects.hash(order, keyed, minDocCount, interval, offset, minBound, maxBound); return Objects.hash(super.hashCode(), order, keyed, minDocCount, interval, offset, minBound, maxBound);
} }
@Override @Override
protected boolean innerEquals(Object obj) { public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
if (super.equals(obj) == false) return false;
HistogramAggregationBuilder other = (HistogramAggregationBuilder) obj; HistogramAggregationBuilder other = (HistogramAggregationBuilder) obj;
return Objects.equals(order, other.order) return Objects.equals(order, other.order)
&& Objects.equals(keyed, other.keyed) && Objects.equals(keyed, other.keyed)
&& Objects.equals(minDocCount, other.minDocCount) && Objects.equals(minDocCount, other.minDocCount)
&& Objects.equals(interval, other.interval) && Objects.equals(interval, other.interval)
&& Objects.equals(offset, other.offset) && Objects.equals(offset, other.offset)
&& Objects.equals(minBound, other.minBound) && Objects.equals(minBound, other.minBound)
&& Objects.equals(maxBound, other.maxBound); && Objects.equals(maxBound, other.maxBound);
} }
} }

View File

@ -598,7 +598,11 @@ public final class InternalAutoDateHistogram extends
} }
@Override @Override
protected boolean doEquals(Object obj) { public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
if (super.equals(obj) == false) return false;
InternalAutoDateHistogram that = (InternalAutoDateHistogram) obj; InternalAutoDateHistogram that = (InternalAutoDateHistogram) obj;
return Objects.equals(buckets, that.buckets) return Objects.equals(buckets, that.buckets)
&& Objects.equals(format, that.format) && Objects.equals(format, that.format)
@ -606,7 +610,7 @@ public final class InternalAutoDateHistogram extends
} }
@Override @Override
protected int doHashCode() { public int hashCode() {
return Objects.hash(buckets, format, bucketInfo); return Objects.hash(super.hashCode(), buckets, format, bucketInfo);
} }
} }

View File

@ -512,7 +512,11 @@ public final class InternalDateHistogram extends InternalMultiBucketAggregation<
} }
@Override @Override
protected boolean doEquals(Object obj) { public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
if (super.equals(obj) == false) return false;
InternalDateHistogram that = (InternalDateHistogram) obj; InternalDateHistogram that = (InternalDateHistogram) obj;
return Objects.equals(buckets, that.buckets) return Objects.equals(buckets, that.buckets)
&& Objects.equals(order, that.order) && Objects.equals(order, that.order)
@ -524,7 +528,7 @@ public final class InternalDateHistogram extends InternalMultiBucketAggregation<
} }
@Override @Override
protected int doHashCode() { public int hashCode() {
return Objects.hash(buckets, order, format, keyed, minDocCount, offset, emptyBucketInfo); return Objects.hash(super.hashCode(), buckets, order, format, keyed, minDocCount, offset, emptyBucketInfo);
} }
} }

View File

@ -489,7 +489,11 @@ public final class InternalHistogram extends InternalMultiBucketAggregation<Inte
} }
@Override @Override
protected boolean doEquals(Object obj) { public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
if (super.equals(obj) == false) return false;
InternalHistogram that = (InternalHistogram) obj; InternalHistogram that = (InternalHistogram) obj;
return Objects.equals(buckets, that.buckets) return Objects.equals(buckets, that.buckets)
&& Objects.equals(emptyBucketInfo, that.emptyBucketInfo) && Objects.equals(emptyBucketInfo, that.emptyBucketInfo)
@ -500,7 +504,7 @@ public final class InternalHistogram extends InternalMultiBucketAggregation<Inte
} }
@Override @Override
protected int doHashCode() { public int hashCode() {
return Objects.hash(buckets, emptyBucketInfo, format, keyed, minDocCount, order); return Objects.hash(super.hashCode(), buckets, emptyBucketInfo, format, keyed, minDocCount, order);
} }
} }

View File

@ -92,17 +92,7 @@ public class MissingAggregationBuilder extends ValuesSourceAggregationBuilder<Va
public XContentBuilder doXContentBody(XContentBuilder builder, Params params) throws IOException { public XContentBuilder doXContentBody(XContentBuilder builder, Params params) throws IOException {
return builder; return builder;
} }
@Override
protected int innerHashCode() {
return 0;
}
@Override
protected boolean innerEquals(Object obj) {
return true;
}
@Override @Override
public String getType() { public String getType() {
return NAME; return NAME;

View File

@ -143,14 +143,16 @@ public class NestedAggregationBuilder extends AbstractAggregationBuilder<NestedA
return new NestedAggregationBuilder(aggregationName, path); return new NestedAggregationBuilder(aggregationName, path);
} }
@Override @Override
protected int doHashCode() { public int hashCode() {
return Objects.hash(path); return Objects.hash(super.hashCode(), path);
} }
@Override @Override
protected boolean doEquals(Object obj) { public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
if (super.equals(obj) == false) return false;
NestedAggregationBuilder other = (NestedAggregationBuilder) obj; NestedAggregationBuilder other = (NestedAggregationBuilder) obj;
return Objects.equals(path, other.path); return Objects.equals(path, other.path);
} }

View File

@ -168,14 +168,16 @@ public class ReverseNestedAggregationBuilder extends AbstractAggregationBuilder<
return factory; return factory;
} }
@Override @Override
protected int doHashCode() { public int hashCode() {
return Objects.hash(path); return Objects.hash(super.hashCode(), path);
} }
@Override @Override
protected boolean doEquals(Object obj) { public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
if (super.equals(obj) == false) return false;
ReverseNestedAggregationBuilder other = (ReverseNestedAggregationBuilder) obj; ReverseNestedAggregationBuilder other = (ReverseNestedAggregationBuilder) obj;
return Objects.equals(path, other.path); return Objects.equals(path, other.path);
} }

View File

@ -140,12 +140,15 @@ public abstract class AbstractRangeBuilder<AB extends AbstractRangeBuilder<AB, R
} }
@Override @Override
protected int innerHashCode() { public int hashCode() {
return Objects.hash(ranges, keyed); return Objects.hash(super.hashCode(), ranges, keyed);
} }
@Override @Override
protected boolean innerEquals(Object obj) { public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
if (super.equals(obj) == false) return false;
AbstractRangeBuilder<AB, R> other = (AbstractRangeBuilder<AB, R>) obj; AbstractRangeBuilder<AB, R> other = (AbstractRangeBuilder<AB, R>) obj;
return Objects.equals(ranges, other.ranges) return Objects.equals(ranges, other.ranges)
&& Objects.equals(keyed, other.keyed); && Objects.equals(keyed, other.keyed);

View File

@ -433,12 +433,15 @@ public class GeoDistanceAggregationBuilder extends ValuesSourceAggregationBuilde
} }
@Override @Override
protected int innerHashCode() { public int hashCode() {
return Objects.hash(origin, ranges, keyed, distanceType, unit); return Objects.hash(super.hashCode(), origin, ranges, keyed, distanceType, unit);
} }
@Override @Override
protected boolean innerEquals(Object obj) { public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
if (super.equals(obj) == false) return false;
GeoDistanceAggregationBuilder other = (GeoDistanceAggregationBuilder) obj; GeoDistanceAggregationBuilder other = (GeoDistanceAggregationBuilder) obj;
return Objects.equals(origin, other.origin) return Objects.equals(origin, other.origin)
&& Objects.equals(ranges, other.ranges) && Objects.equals(ranges, other.ranges)

View File

@ -283,16 +283,20 @@ public final class InternalBinaryRange
return builder; return builder;
} }
@Override @Override
public boolean doEquals(Object obj) { public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
if (super.equals(obj) == false) return false;
InternalBinaryRange that = (InternalBinaryRange) obj; InternalBinaryRange that = (InternalBinaryRange) obj;
return Objects.equals(buckets, that.buckets) return Objects.equals(buckets, that.buckets)
&& Objects.equals(format, that.format) && Objects.equals(format, that.format)
&& Objects.equals(keyed, that.keyed); && Objects.equals(keyed, that.keyed);
} }
@Override public int hashCode() {
public int doHashCode() { return Objects.hash(super.hashCode(), buckets, format, keyed);
return Objects.hash(buckets, format, keyed);
} }
} }

View File

@ -345,12 +345,16 @@ public class InternalRange<B extends InternalRange.Bucket, R extends InternalRan
} }
@Override @Override
protected int doHashCode() { public int hashCode() {
return Objects.hash(ranges, format, keyed); return Objects.hash(super.hashCode(), ranges, format, keyed);
} }
@Override @Override
protected boolean doEquals(Object obj) { public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
if (super.equals(obj) == false) return false;
InternalRange<?,?> that = (InternalRange<?,?>) obj; InternalRange<?,?> that = (InternalRange<?,?>) obj;
return Objects.equals(ranges, that.ranges) return Objects.equals(ranges, that.ranges)
&& Objects.equals(format, that.format) && Objects.equals(format, that.format)

View File

@ -387,14 +387,17 @@ public final class IpRangeAggregationBuilder
} }
@Override @Override
protected int innerHashCode() { public int hashCode() {
return Objects.hash(keyed, ranges); return Objects.hash(super.hashCode(), keyed, ranges);
} }
@Override @Override
protected boolean innerEquals(Object obj) { public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
if (super.equals(obj) == false) return false;
IpRangeAggregationBuilder that = (IpRangeAggregationBuilder) obj; IpRangeAggregationBuilder that = (IpRangeAggregationBuilder) obj;
return keyed == that.keyed return keyed == that.keyed
&& ranges.equals(that.ranges); && ranges.equals(that.ranges);
} }
} }

View File

@ -165,16 +165,19 @@ public class DiversifiedAggregationBuilder extends ValuesSourceAggregationBuilde
} }
@Override @Override
protected int innerHashCode() { public int hashCode() {
return Objects.hash(shardSize, maxDocsPerValue, executionHint); return Objects.hash(super.hashCode(), shardSize, maxDocsPerValue, executionHint);
} }
@Override @Override
protected boolean innerEquals(Object obj) { public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
if (super.equals(obj) == false) return false;
DiversifiedAggregationBuilder other = (DiversifiedAggregationBuilder) obj; DiversifiedAggregationBuilder other = (DiversifiedAggregationBuilder) obj;
return Objects.equals(shardSize, other.shardSize) return Objects.equals(shardSize, other.shardSize)
&& Objects.equals(maxDocsPerValue, other.maxDocsPerValue) && Objects.equals(maxDocsPerValue, other.maxDocsPerValue)
&& Objects.equals(executionHint, other.executionHint); && Objects.equals(executionHint, other.executionHint);
} }
@Override @Override

View File

@ -126,12 +126,15 @@ public class SamplerAggregationBuilder extends AbstractAggregationBuilder<Sample
} }
@Override @Override
protected int doHashCode() { public int hashCode() {
return Objects.hash(shardSize); return Objects.hash(super.hashCode(), shardSize);
} }
@Override @Override
protected boolean doEquals(Object obj) { public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
if (super.equals(obj) == false) return false;
SamplerAggregationBuilder other = (SamplerAggregationBuilder) obj; SamplerAggregationBuilder other = (SamplerAggregationBuilder) obj;
return Objects.equals(shardSize, other.shardSize); return Objects.equals(shardSize, other.shardSize);
} }

View File

@ -109,10 +109,13 @@ public abstract class InternalMappedSignificantTerms<
} }
@Override @Override
protected boolean doEquals(Object obj) { public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
if (super.equals(obj) == false) return false;
InternalMappedSignificantTerms<?, ?> that = (InternalMappedSignificantTerms<?, ?>) obj; InternalMappedSignificantTerms<?, ?> that = (InternalMappedSignificantTerms<?, ?>) obj;
return super.doEquals(obj) return Objects.equals(format, that.format)
&& Objects.equals(format, that.format)
&& subsetSize == that.subsetSize && subsetSize == that.subsetSize
&& supersetSize == that.supersetSize && supersetSize == that.supersetSize
&& Objects.equals(significanceHeuristic, that.significanceHeuristic) && Objects.equals(significanceHeuristic, that.significanceHeuristic)
@ -121,8 +124,8 @@ public abstract class InternalMappedSignificantTerms<
} }
@Override @Override
protected int doHashCode() { public int hashCode() {
return Objects.hash(super.doHashCode(), format, subsetSize, supersetSize, significanceHeuristic, buckets, bucketMap); return Objects.hash(super.hashCode(), format, subsetSize, supersetSize, significanceHeuristic, buckets, bucketMap);
} }
@Override @Override

View File

@ -272,12 +272,16 @@ public abstract class InternalSignificantTerms<A extends InternalSignificantTerm
protected abstract SignificanceHeuristic getSignificanceHeuristic(); protected abstract SignificanceHeuristic getSignificanceHeuristic();
@Override @Override
protected int doHashCode() { public int hashCode() {
return Objects.hash(minDocCount, requiredSize); return Objects.hash(super.hashCode(), minDocCount, requiredSize);
} }
@Override @Override
protected boolean doEquals(Object obj) { public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
if (super.equals(obj) == false) return false;
InternalSignificantTerms<?, ?> that = (InternalSignificantTerms<?, ?>) obj; InternalSignificantTerms<?, ?> that = (InternalSignificantTerms<?, ?>) obj;
return Objects.equals(minDocCount, that.minDocCount) return Objects.equals(minDocCount, that.minDocCount)
&& Objects.equals(requiredSize, that.requiredSize); && Objects.equals(requiredSize, that.requiredSize);

View File

@ -103,6 +103,10 @@ public class SignificantStringTerms extends InternalMappedSignificantTerms<Signi
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
if (super.equals(obj) == false) return false;
return super.equals(obj) && Objects.equals(termBytes, ((SignificantStringTerms.Bucket) obj).termBytes); return super.equals(obj) && Objects.equals(termBytes, ((SignificantStringTerms.Bucket) obj).termBytes);
} }

View File

@ -307,12 +307,15 @@ public class SignificantTermsAggregationBuilder extends ValuesSourceAggregationB
} }
@Override @Override
protected int innerHashCode() { public int hashCode() {
return Objects.hash(bucketCountThresholds, executionHint, filterBuilder, includeExclude, significanceHeuristic); return Objects.hash(super.hashCode(), bucketCountThresholds, executionHint, filterBuilder, includeExclude, significanceHeuristic);
} }
@Override @Override
protected boolean innerEquals(Object obj) { public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
if (super.equals(obj) == false) return false;
SignificantTermsAggregationBuilder other = (SignificantTermsAggregationBuilder) obj; SignificantTermsAggregationBuilder other = (SignificantTermsAggregationBuilder) obj;
return Objects.equals(bucketCountThresholds, other.bucketCountThresholds) return Objects.equals(bucketCountThresholds, other.bucketCountThresholds)
&& Objects.equals(executionHint, other.executionHint) && Objects.equals(executionHint, other.executionHint)

View File

@ -378,13 +378,17 @@ public class SignificantTextAggregationBuilder extends AbstractAggregationBuilde
} }
@Override @Override
protected int doHashCode() { public int hashCode() {
return Objects.hash(bucketCountThresholds, fieldName, filterDuplicateText, filterBuilder, return Objects.hash(super.hashCode(), bucketCountThresholds, fieldName,
includeExclude, significanceHeuristic, Arrays.hashCode(sourceFieldNames)); filterDuplicateText, filterBuilder,
includeExclude, significanceHeuristic, Arrays.hashCode(sourceFieldNames));
} }
@Override @Override
protected boolean doEquals(Object obj) { public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
if (super.equals(obj) == false) return false;
SignificantTextAggregationBuilder other = (SignificantTextAggregationBuilder) obj; SignificantTextAggregationBuilder other = (SignificantTextAggregationBuilder) obj;
return Objects.equals(bucketCountThresholds, other.bucketCountThresholds) return Objects.equals(bucketCountThresholds, other.bucketCountThresholds)
&& Objects.equals(fieldName, other.fieldName) && Objects.equals(fieldName, other.fieldName)

View File

@ -115,10 +115,13 @@ public abstract class InternalMappedTerms<A extends InternalTerms<A, B>, B exten
} }
@Override @Override
protected boolean doEquals(Object obj) { public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
if (super.equals(obj) == false) return false;
InternalMappedTerms<?,?> that = (InternalMappedTerms<?,?>) obj; InternalMappedTerms<?,?> that = (InternalMappedTerms<?,?>) obj;
return super.doEquals(obj) return Objects.equals(buckets, that.buckets)
&& Objects.equals(buckets, that.buckets)
&& Objects.equals(format, that.format) && Objects.equals(format, that.format)
&& Objects.equals(otherDocCount, that.otherDocCount) && Objects.equals(otherDocCount, that.otherDocCount)
&& Objects.equals(showTermDocCountError, that.showTermDocCountError) && Objects.equals(showTermDocCountError, that.showTermDocCountError)
@ -127,8 +130,8 @@ public abstract class InternalMappedTerms<A extends InternalTerms<A, B>, B exten
} }
@Override @Override
protected int doHashCode() { public int hashCode() {
return Objects.hash(super.doHashCode(), buckets, format, otherDocCount, showTermDocCountError, shardSize); return Objects.hash(super.hashCode(), buckets, format, otherDocCount, showTermDocCountError, shardSize);
} }
@Override @Override

View File

@ -326,7 +326,11 @@ public abstract class InternalTerms<A extends InternalTerms<A, B>, B extends Int
protected abstract B[] createBucketsArray(int size); protected abstract B[] createBucketsArray(int size);
@Override @Override
protected boolean doEquals(Object obj) { public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
if (super.equals(obj) == false) return false;
InternalTerms<?,?> that = (InternalTerms<?,?>) obj; InternalTerms<?,?> that = (InternalTerms<?,?>) obj;
return Objects.equals(minDocCount, that.minDocCount) return Objects.equals(minDocCount, that.minDocCount)
&& Objects.equals(order, that.order) && Objects.equals(order, that.order)
@ -334,8 +338,8 @@ public abstract class InternalTerms<A extends InternalTerms<A, B>, B extends Int
} }
@Override @Override
protected int doHashCode() { public int hashCode() {
return Objects.hash(minDocCount, order, requiredSize); return Objects.hash(super.hashCode(), minDocCount, order, requiredSize);
} }
protected static XContentBuilder doXContentCommon(XContentBuilder builder, Params params, protected static XContentBuilder doXContentCommon(XContentBuilder builder, Params params,

View File

@ -358,19 +358,23 @@ public class TermsAggregationBuilder extends ValuesSourceAggregationBuilder<Valu
} }
@Override @Override
protected int innerHashCode() { public int hashCode() {
return Objects.hash(bucketCountThresholds, collectMode, executionHint, includeExclude, order, showTermDocCountError); return Objects.hash(super.hashCode(), bucketCountThresholds, collectMode,
executionHint, includeExclude, order, showTermDocCountError);
} }
@Override @Override
protected boolean innerEquals(Object obj) { public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
if (super.equals(obj) == false) return false;
TermsAggregationBuilder other = (TermsAggregationBuilder) obj; TermsAggregationBuilder other = (TermsAggregationBuilder) obj;
return Objects.equals(bucketCountThresholds, other.bucketCountThresholds) return Objects.equals(bucketCountThresholds, other.bucketCountThresholds)
&& Objects.equals(collectMode, other.collectMode) && Objects.equals(collectMode, other.collectMode)
&& Objects.equals(executionHint, other.executionHint) && Objects.equals(executionHint, other.executionHint)
&& Objects.equals(includeExclude, other.includeExclude) && Objects.equals(includeExclude, other.includeExclude)
&& Objects.equals(order, other.order) && Objects.equals(order, other.order)
&& Objects.equals(showTermDocCountError, other.showTermDocCountError); && Objects.equals(showTermDocCountError, other.showTermDocCountError);
} }
@Override @Override

View File

@ -150,7 +150,11 @@ abstract class AbstractInternalHDRPercentiles extends InternalNumericMetricsAggr
} }
@Override @Override
protected boolean doEquals(Object obj) { public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
if (super.equals(obj) == false) return false;
AbstractInternalHDRPercentiles that = (AbstractInternalHDRPercentiles) obj; AbstractInternalHDRPercentiles that = (AbstractInternalHDRPercentiles) obj;
return keyed == that.keyed return keyed == that.keyed
&& Arrays.equals(keys, that.keys) && Arrays.equals(keys, that.keys)
@ -158,10 +162,14 @@ abstract class AbstractInternalHDRPercentiles extends InternalNumericMetricsAggr
} }
@Override @Override
protected int doHashCode() { public int hashCode() {
// we cannot use state.hashCode at the moment because of: // we cannot use state.hashCode at the moment because of:
// https://github.com/HdrHistogram/HdrHistogram/issues/81 // https://github.com/HdrHistogram/HdrHistogram/issues/81
// TODO: upgrade the HDRHistogram library // TODO: upgrade the HDRHistogram library
return Objects.hash(keyed, Arrays.hashCode(keys), state.getIntegerToDoubleValueConversionRatio(), state.getTotalCount()); return Objects.hash(super.hashCode(),
keyed,
Arrays.hashCode(keys),
state.getIntegerToDoubleValueConversionRatio(),
state.getTotalCount());
} }
} }

View File

@ -133,7 +133,11 @@ abstract class AbstractInternalTDigestPercentiles extends InternalNumericMetrics
} }
@Override @Override
protected boolean doEquals(Object obj) { public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
if (super.equals(obj) == false) return false;
AbstractInternalTDigestPercentiles that = (AbstractInternalTDigestPercentiles) obj; AbstractInternalTDigestPercentiles that = (AbstractInternalTDigestPercentiles) obj;
return keyed == that.keyed return keyed == that.keyed
&& Arrays.equals(keys, that.keys) && Arrays.equals(keys, that.keys)
@ -141,7 +145,7 @@ abstract class AbstractInternalTDigestPercentiles extends InternalNumericMetrics
} }
@Override @Override
protected int doHashCode() { public int hashCode() {
return Objects.hash(keyed, Arrays.hashCode(keys), state); return Objects.hash(super.hashCode(), keyed, Arrays.hashCode(keys), state);
} }
} }

View File

@ -88,16 +88,6 @@ public class AvgAggregationBuilder extends ValuesSourceAggregationBuilder.LeafOn
return builder; return builder;
} }
@Override
protected int innerHashCode() {
return 0;
}
@Override
protected boolean innerEquals(Object obj) {
return true;
}
@Override @Override
public String getType() { public String getType() {
return NAME; return NAME;

View File

@ -137,12 +137,15 @@ public final class CardinalityAggregationBuilder
} }
@Override @Override
protected int innerHashCode() { public int hashCode() {
return Objects.hash(precisionThreshold); return Objects.hash(super.hashCode(), precisionThreshold);
} }
@Override @Override
protected boolean innerEquals(Object obj) { public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
if (super.equals(obj) == false) return false;
CardinalityAggregationBuilder other = (CardinalityAggregationBuilder) obj; CardinalityAggregationBuilder other = (CardinalityAggregationBuilder) obj;
return Objects.equals(precisionThreshold, other.precisionThreshold); return Objects.equals(precisionThreshold, other.precisionThreshold);
} }

View File

@ -110,12 +110,15 @@ public class ExtendedStatsAggregationBuilder
} }
@Override @Override
protected int innerHashCode() { public int hashCode() {
return Objects.hash(sigma); return Objects.hash(super.hashCode(), sigma);
} }
@Override @Override
protected boolean innerEquals(Object obj) { public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
if (super.equals(obj) == false) return false;
ExtendedStatsAggregationBuilder other = (ExtendedStatsAggregationBuilder) obj; ExtendedStatsAggregationBuilder other = (ExtendedStatsAggregationBuilder) obj;
return Objects.equals(sigma, other.sigma); return Objects.equals(sigma, other.sigma);
} }

View File

@ -110,12 +110,15 @@ public class GeoBoundsAggregationBuilder extends ValuesSourceAggregationBuilder<
} }
@Override @Override
protected int innerHashCode() { public int hashCode() {
return Objects.hash(wrapLongitude); return Objects.hash(super.hashCode(), wrapLongitude);
} }
@Override @Override
protected boolean innerEquals(Object obj) { public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
if (super.equals(obj) == false) return false;
GeoBoundsAggregationBuilder other = (GeoBoundsAggregationBuilder) obj; GeoBoundsAggregationBuilder other = (GeoBoundsAggregationBuilder) obj;
return Objects.equals(wrapLongitude, other.wrapLongitude); return Objects.equals(wrapLongitude, other.wrapLongitude);
} }

View File

@ -88,16 +88,6 @@ public class GeoCentroidAggregationBuilder
return builder; return builder;
} }
@Override
protected int innerHashCode() {
return 0;
}
@Override
protected boolean innerEquals(Object obj) {
return true;
}
@Override @Override
public String getType() { public String getType() {
return NAME; return NAME;

View File

@ -118,12 +118,15 @@ public class InternalAvg extends InternalNumericMetricsAggregation.SingleValue i
} }
@Override @Override
protected int doHashCode() { public int hashCode() {
return Objects.hash(sum, count, format.getWriteableName()); return Objects.hash(super.hashCode(), sum, count, format.getWriteableName());
} }
@Override @Override
protected boolean doEquals(Object obj) { public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
if (super.equals(obj) == false) return false;
InternalAvg other = (InternalAvg) obj; InternalAvg other = (InternalAvg) obj;
return Objects.equals(sum, other.sum) && return Objects.equals(sum, other.sum) &&
Objects.equals(count, other.count) && Objects.equals(count, other.count) &&

View File

@ -30,6 +30,7 @@ import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects;
public final class InternalCardinality extends InternalNumericMetricsAggregation.SingleValue implements Cardinality { public final class InternalCardinality extends InternalNumericMetricsAggregation.SingleValue implements Cardinality {
private final HyperLogLogPlusPlus counts; private final HyperLogLogPlusPlus counts;
@ -117,12 +118,16 @@ public final class InternalCardinality extends InternalNumericMetricsAggregation
} }
@Override @Override
protected int doHashCode() { public int hashCode() {
return counts.hashCode(0); return Objects.hash(super.hashCode(), counts.hashCode(0));
} }
@Override @Override
protected boolean doEquals(Object obj) { public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
if (super.equals(obj) == false) return false;
InternalCardinality other = (InternalCardinality) obj; InternalCardinality other = (InternalCardinality) obj;
return counts.equals(0, other.counts); return counts.equals(0, other.counts);
} }

View File

@ -215,15 +215,18 @@ public class InternalExtendedStats extends InternalStats implements ExtendedStat
} }
@Override @Override
protected int doHashCode() { public int hashCode() {
return Objects.hash(super.doHashCode(), sumOfSqrs, sigma); return Objects.hash(super.hashCode(), sumOfSqrs, sigma);
} }
@Override @Override
protected boolean doEquals(Object obj) { public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
if (super.equals(obj) == false) return false;
InternalExtendedStats other = (InternalExtendedStats) obj; InternalExtendedStats other = (InternalExtendedStats) obj;
return super.doEquals(obj) && return Double.compare(sumOfSqrs, other.sumOfSqrs) == 0 &&
Double.compare(sumOfSqrs, other.sumOfSqrs) == 0 &&
Double.compare(sigma, other.sigma) == 0; Double.compare(sigma, other.sigma) == 0;
} }
} }

View File

@ -252,7 +252,11 @@ public class InternalGeoBounds extends InternalAggregation implements GeoBounds
} }
@Override @Override
protected boolean doEquals(Object obj) { public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
if (super.equals(obj) == false) return false;
InternalGeoBounds other = (InternalGeoBounds) obj; InternalGeoBounds other = (InternalGeoBounds) obj;
return top == other.top && return top == other.top &&
bottom == other.bottom && bottom == other.bottom &&
@ -264,7 +268,7 @@ public class InternalGeoBounds extends InternalAggregation implements GeoBounds
} }
@Override @Override
protected int doHashCode() { public int hashCode() {
return Objects.hash(bottom, posLeft, posRight, negLeft, negRight, wrapLongitude); return Objects.hash(super.hashCode(), bottom, posLeft, posRight, negLeft, negRight, wrapLongitude);
} }
} }

View File

@ -180,15 +180,18 @@ public class InternalGeoCentroid extends InternalAggregation implements GeoCentr
} }
@Override @Override
public boolean doEquals(Object o) { public boolean equals(Object obj) {
InternalGeoCentroid that = (InternalGeoCentroid) o; if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
if (super.equals(obj) == false) return false;
InternalGeoCentroid that = (InternalGeoCentroid) obj;
return count == that.count && return count == that.count &&
Objects.equals(centroid, that.centroid); Objects.equals(centroid, that.centroid);
} }
@Override @Override
protected int doHashCode() { public int hashCode() {
return Objects.hash(centroid, count); return Objects.hash(super.hashCode(), centroid, count);
} }
@Override @Override

View File

@ -90,12 +90,15 @@ public class InternalMax extends InternalNumericMetricsAggregation.SingleValue i
} }
@Override @Override
protected int doHashCode() { public int hashCode() {
return Objects.hash(max); return Objects.hash(super.hashCode(), max);
} }
@Override @Override
protected boolean doEquals(Object obj) { public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
if (super.equals(obj) == false) return false;
InternalMax other = (InternalMax) obj; InternalMax other = (InternalMax) obj;
return Objects.equals(max, other.max); return Objects.equals(max, other.max);
} }

View File

@ -106,12 +106,15 @@ public class InternalMedianAbsoluteDeviation extends InternalNumericMetricsAggre
} }
@Override @Override
protected int doHashCode() { public int hashCode() {
return Objects.hash(valuesSketch); return Objects.hash(super.hashCode(), valuesSketch);
} }
@Override @Override
protected boolean doEquals(Object obj) { public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
if (super.equals(obj) == false) return false;
InternalMedianAbsoluteDeviation other = (InternalMedianAbsoluteDeviation) obj; InternalMedianAbsoluteDeviation other = (InternalMedianAbsoluteDeviation) obj;
return Objects.equals(valuesSketch, other.valuesSketch); return Objects.equals(valuesSketch, other.valuesSketch);
} }

View File

@ -90,12 +90,15 @@ public class InternalMin extends InternalNumericMetricsAggregation.SingleValue i
} }
@Override @Override
protected int doHashCode() { public int hashCode() {
return Objects.hash(min); return Objects.hash(super.hashCode(), min);
} }
@Override @Override
protected boolean doEquals(Object obj) { public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
if (super.equals(obj) == false) return false;
InternalMin other = (InternalMin) obj; InternalMin other = (InternalMin) obj;
return Objects.equals(min, other.min); return Objects.equals(min, other.min);
} }

View File

@ -107,19 +107,16 @@ public abstract class InternalNumericMetricsAggregation extends InternalAggregat
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(format, super.hashCode()); return Objects.hash(super.hashCode(), format);
} }
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (obj == null) { if (this == obj) return true;
return false; if (obj == null || getClass() != obj.getClass()) return false;
} if (super.equals(obj) == false) return false;
if (obj.getClass() != getClass()) {
return false;
}
InternalNumericMetricsAggregation other = (InternalNumericMetricsAggregation) obj; InternalNumericMetricsAggregation other = (InternalNumericMetricsAggregation) obj;
return super.equals(obj) && return Objects.equals(format, other.format);
Objects.equals(format, other.format);
} }
} }

View File

@ -135,15 +135,19 @@ public class InternalScriptedMetric extends InternalAggregation implements Scrip
} }
@Override @Override
protected boolean doEquals(Object obj) { public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
if (super.equals(obj) == false) return false;
InternalScriptedMetric other = (InternalScriptedMetric) obj; InternalScriptedMetric other = (InternalScriptedMetric) obj;
return Objects.equals(reduceScript, other.reduceScript) && return Objects.equals(reduceScript, other.reduceScript) &&
Objects.equals(aggregation, other.aggregation); Objects.equals(aggregation, other.aggregation);
} }
@Override @Override
protected int doHashCode() { public int hashCode() {
return Objects.hash(reduceScript, aggregation); return Objects.hash(super.hashCode(), reduceScript, aggregation);
} }
} }

View File

@ -212,12 +212,16 @@ public class InternalStats extends InternalNumericMetricsAggregation.MultiValue
} }
@Override @Override
protected int doHashCode() { public int hashCode() {
return Objects.hash(count, min, max, sum); return Objects.hash(super.hashCode(), count, min, max, sum);
} }
@Override @Override
protected boolean doEquals(Object obj) { public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
if (super.equals(obj) == false) return false;
InternalStats other = (InternalStats) obj; InternalStats other = (InternalStats) obj;
return count == other.count && return count == other.count &&
Double.compare(min, other.min) == 0 && Double.compare(min, other.min) == 0 &&

View File

@ -100,12 +100,16 @@ public class InternalSum extends InternalNumericMetricsAggregation.SingleValue i
} }
@Override @Override
protected int doHashCode() { public int hashCode() {
return Objects.hashCode(sum); return Objects.hash(super.hashCode(), sum);
} }
@Override @Override
protected boolean doEquals(Object obj) { public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
if (super.equals(obj) == false) return false;
InternalSum that = (InternalSum) obj; InternalSum that = (InternalSum) obj;
return Objects.equals(sum, that.sum); return Objects.equals(sum, that.sum);
} }

View File

@ -180,7 +180,11 @@ public class InternalTopHits extends InternalAggregation implements TopHits {
// Equals and hashcode implemented for testing round trips // Equals and hashcode implemented for testing round trips
@Override @Override
protected boolean doEquals(Object obj) { public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
if (super.equals(obj) == false) return false;
InternalTopHits other = (InternalTopHits) obj; InternalTopHits other = (InternalTopHits) obj;
if (from != other.from) return false; if (from != other.from) return false;
if (size != other.size) return false; if (size != other.size) return false;
@ -207,9 +211,10 @@ public class InternalTopHits extends InternalAggregation implements TopHits {
} }
@Override @Override
protected int doHashCode() { public int hashCode() {
int hashCode = from; int hashCode = super.hashCode();
hashCode = 31 * hashCode + size; hashCode = 31 * hashCode + Integer.hashCode(from);
hashCode = 31 * hashCode + Integer.hashCode(size);
hashCode = 31 * hashCode + Long.hashCode(topDocs.topDocs.totalHits.value); hashCode = 31 * hashCode + Long.hashCode(topDocs.topDocs.totalHits.value);
hashCode = 31 * hashCode + topDocs.topDocs.totalHits.relation.hashCode(); hashCode = 31 * hashCode + topDocs.topDocs.totalHits.relation.hashCode();
for (int d = 0; d < topDocs.topDocs.scoreDocs.length; d++) { for (int d = 0; d < topDocs.topDocs.scoreDocs.length; d++) {

View File

@ -90,12 +90,16 @@ public class InternalValueCount extends InternalNumericMetricsAggregation.Single
} }
@Override @Override
protected int doHashCode() { public int hashCode() {
return Objects.hash(value); return Objects.hash(super.hashCode(), value);
} }
@Override @Override
protected boolean doEquals(Object obj) { public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
if (super.equals(obj) == false) return false;
InternalValueCount that = (InternalValueCount) obj; InternalValueCount that = (InternalValueCount) obj;
return Objects.equals(this.value, that.value); return Objects.equals(this.value, that.value);
} }

View File

@ -129,12 +129,15 @@ public class InternalWeightedAvg extends InternalNumericMetricsAggregation.Singl
} }
@Override @Override
protected int doHashCode() { public int hashCode() {
return Objects.hash(sum, weight, format.getWriteableName()); return Objects.hash(super.hashCode(), sum, weight, format.getWriteableName());
} }
@Override @Override
protected boolean doEquals(Object obj) { public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
if (super.equals(obj) == false) return false;
InternalWeightedAvg other = (InternalWeightedAvg) obj; InternalWeightedAvg other = (InternalWeightedAvg) obj;
return Objects.equals(sum, other.sum) && return Objects.equals(sum, other.sum) &&
Objects.equals(weight, other.weight) && Objects.equals(weight, other.weight) &&

View File

@ -88,16 +88,6 @@ public class MaxAggregationBuilder extends ValuesSourceAggregationBuilder.LeafOn
return builder; return builder;
} }
@Override
protected int innerHashCode() {
return 0;
}
@Override
protected boolean innerEquals(Object obj) {
return true;
}
@Override @Override
public String getType() { public String getType() {
return NAME; return NAME;

View File

@ -123,12 +123,15 @@ public class MedianAbsoluteDeviationAggregationBuilder extends LeafOnly<ValuesSo
} }
@Override @Override
protected int innerHashCode() { public int hashCode() {
return Objects.hash(compression); return Objects.hash(super.hashCode(), compression);
} }
@Override @Override
protected boolean innerEquals(Object obj) { public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
if (super.equals(obj) == false) return false;
MedianAbsoluteDeviationAggregationBuilder other = (MedianAbsoluteDeviationAggregationBuilder) obj; MedianAbsoluteDeviationAggregationBuilder other = (MedianAbsoluteDeviationAggregationBuilder) obj;
return Objects.equals(compression, other.compression); return Objects.equals(compression, other.compression);
} }

View File

@ -88,16 +88,6 @@ public class MinAggregationBuilder extends ValuesSourceAggregationBuilder.LeafOn
return builder; return builder;
} }
@Override
protected int innerHashCode() {
return 0;
}
@Override
protected boolean innerEquals(Object obj) {
return true;
}
@Override @Override
public String getType() { public String getType() {
return NAME; return NAME;

View File

@ -269,37 +269,40 @@ public class PercentileRanksAggregationBuilder extends LeafOnly<ValuesSource.Num
} }
@Override @Override
protected boolean innerEquals(Object obj) { public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
if (super.equals(obj) == false) return false;
PercentileRanksAggregationBuilder other = (PercentileRanksAggregationBuilder) obj; PercentileRanksAggregationBuilder other = (PercentileRanksAggregationBuilder) obj;
if (!Objects.equals(method, other.method)) { if (Objects.equals(method, other.method) == false) {
return false; return false;
} }
boolean equalSettings = false; boolean equalSettings = false;
switch (method) { switch (method) {
case HDR: case HDR:
equalSettings = Objects.equals(numberOfSignificantValueDigits, other.numberOfSignificantValueDigits); equalSettings = Objects.equals(numberOfSignificantValueDigits, other.numberOfSignificantValueDigits);
break; break;
case TDIGEST: case TDIGEST:
equalSettings = Objects.equals(compression, other.compression); equalSettings = Objects.equals(compression, other.compression);
break; break;
default: default:
throw new IllegalStateException("Illegal method [" + method + "]"); throw new IllegalStateException("Illegal method [" + method + "]");
} }
return equalSettings return equalSettings
&& Objects.deepEquals(values, other.values) && Objects.deepEquals(values, other.values)
&& Objects.equals(keyed, other.keyed) && Objects.equals(keyed, other.keyed)
&& Objects.equals(method, other.method); && Objects.equals(method, other.method);
} }
@Override @Override
protected int innerHashCode() { public int hashCode() {
switch (method) { switch (method) {
case HDR: case HDR:
return Objects.hash(Arrays.hashCode(values), keyed, numberOfSignificantValueDigits, method); return Objects.hash(super.hashCode(), Arrays.hashCode(values), keyed, numberOfSignificantValueDigits, method);
case TDIGEST: case TDIGEST:
return Objects.hash(Arrays.hashCode(values), keyed, compression, method); return Objects.hash(super.hashCode(), Arrays.hashCode(values), keyed, compression, method);
default: default:
throw new IllegalStateException("Illegal method [" + method + "]"); throw new IllegalStateException("Illegal method [" + method + "]");
} }
} }

View File

@ -292,35 +292,39 @@ public class PercentilesAggregationBuilder extends LeafOnly<ValuesSource.Numeric
} }
@Override @Override
protected boolean innerEquals(Object obj) { public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
if (super.equals(obj) == false) return false;
PercentilesAggregationBuilder other = (PercentilesAggregationBuilder) obj; PercentilesAggregationBuilder other = (PercentilesAggregationBuilder) obj;
if (!Objects.equals(method, other.method)) { if (Objects.equals(method, other.method) == false) {
return false; return false;
} }
boolean equalSettings = false; boolean equalSettings = false;
switch (method) { switch (method) {
case HDR: case HDR:
equalSettings = Objects.equals(numberOfSignificantValueDigits, other.numberOfSignificantValueDigits); equalSettings = Objects.equals(numberOfSignificantValueDigits, other.numberOfSignificantValueDigits);
break; break;
case TDIGEST: case TDIGEST:
equalSettings = Objects.equals(compression, other.compression); equalSettings = Objects.equals(compression, other.compression);
break; break;
default: default:
throw new IllegalStateException("Illegal method [" + method.toString() + "]"); throw new IllegalStateException("Illegal method [" + method.toString() + "]");
} }
return equalSettings return equalSettings
&& Objects.deepEquals(percents, other.percents) && Objects.deepEquals(percents, other.percents)
&& Objects.equals(keyed, other.keyed) && Objects.equals(keyed, other.keyed)
&& Objects.equals(method, other.method); && Objects.equals(method, other.method);
} }
@Override @Override
protected int innerHashCode() { public int hashCode() {
switch (method) { switch (method) {
case HDR: case HDR:
return Objects.hash(Arrays.hashCode(percents), keyed, numberOfSignificantValueDigits, method); return Objects.hash(super.hashCode(), Arrays.hashCode(percents), keyed, numberOfSignificantValueDigits, method);
case TDIGEST: case TDIGEST:
return Objects.hash(Arrays.hashCode(percents), keyed, compression, method); return Objects.hash(super.hashCode(), Arrays.hashCode(percents), keyed, compression, method);
default: default:
throw new IllegalStateException("Illegal method [" + method.toString() + "]"); throw new IllegalStateException("Illegal method [" + method.toString() + "]");
} }

View File

@ -325,18 +325,21 @@ public class ScriptedMetricAggregationBuilder extends AbstractAggregationBuilder
} }
@Override @Override
protected int doHashCode() { public int hashCode() {
return Objects.hash(initScript, mapScript, combineScript, reduceScript, params); return Objects.hash(super.hashCode(), initScript, mapScript, combineScript, reduceScript, params);
} }
@Override @Override
protected boolean doEquals(Object obj) { public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
if (super.equals(obj) == false) return false;
ScriptedMetricAggregationBuilder other = (ScriptedMetricAggregationBuilder) obj; ScriptedMetricAggregationBuilder other = (ScriptedMetricAggregationBuilder) obj;
return Objects.equals(initScript, other.initScript) return Objects.equals(initScript, other.initScript)
&& Objects.equals(mapScript, other.mapScript) && Objects.equals(mapScript, other.mapScript)
&& Objects.equals(combineScript, other.combineScript) && Objects.equals(combineScript, other.combineScript)
&& Objects.equals(reduceScript, other.reduceScript) && Objects.equals(reduceScript, other.reduceScript)
&& Objects.equals(params, other.params); && Objects.equals(params, other.params);
} }
} }

View File

@ -89,16 +89,6 @@ public class StatsAggregationBuilder extends ValuesSourceAggregationBuilder.Leaf
return builder; return builder;
} }
@Override
protected int innerHashCode() {
return 0;
}
@Override
protected boolean innerEquals(Object obj) {
return true;
}
@Override @Override
public String getType() { public String getType() {
return NAME; return NAME;

View File

@ -88,16 +88,6 @@ public class SumAggregationBuilder extends ValuesSourceAggregationBuilder.LeafOn
return builder; return builder;
} }
@Override
protected int innerHashCode() {
return 0;
}
@Override
protected boolean innerEquals(Object obj) {
return true;
}
@Override @Override
public String getType() { public String getType() {
return NAME; return NAME;

View File

@ -775,26 +775,31 @@ public class TopHitsAggregationBuilder extends AbstractAggregationBuilder<TopHit
} }
@Override @Override
protected int doHashCode() { public int hashCode() {
return Objects.hash(explain, fetchSourceContext, docValueFields, storedFieldsContext, from, highlightBuilder, return Objects.hash(super.hashCode(), explain, fetchSourceContext, docValueFields,
scriptFields, size, sorts, trackScores, version, seqNoAndPrimaryTerm); storedFieldsContext, from, highlightBuilder,
scriptFields, size, sorts, trackScores, version,
seqNoAndPrimaryTerm);
} }
@Override @Override
protected boolean doEquals(Object obj) { public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
if (super.equals(obj) == false) return false;
TopHitsAggregationBuilder other = (TopHitsAggregationBuilder) obj; TopHitsAggregationBuilder other = (TopHitsAggregationBuilder) obj;
return Objects.equals(explain, other.explain) return Objects.equals(explain, other.explain)
&& Objects.equals(fetchSourceContext, other.fetchSourceContext) && Objects.equals(fetchSourceContext, other.fetchSourceContext)
&& Objects.equals(docValueFields, other.docValueFields) && Objects.equals(docValueFields, other.docValueFields)
&& Objects.equals(storedFieldsContext, other.storedFieldsContext) && Objects.equals(storedFieldsContext, other.storedFieldsContext)
&& Objects.equals(from, other.from) && Objects.equals(from, other.from)
&& Objects.equals(highlightBuilder, other.highlightBuilder) && Objects.equals(highlightBuilder, other.highlightBuilder)
&& Objects.equals(scriptFields, other.scriptFields) && Objects.equals(scriptFields, other.scriptFields)
&& Objects.equals(size, other.size) && Objects.equals(size, other.size)
&& Objects.equals(sorts, other.sorts) && Objects.equals(sorts, other.sorts)
&& Objects.equals(trackScores, other.trackScores) && Objects.equals(trackScores, other.trackScores)
&& Objects.equals(version, other.version) && Objects.equals(version, other.version)
&& Objects.equals(seqNoAndPrimaryTerm, other.seqNoAndPrimaryTerm); && Objects.equals(seqNoAndPrimaryTerm, other.seqNoAndPrimaryTerm);
} }
@Override @Override

View File

@ -93,16 +93,6 @@ public class ValueCountAggregationBuilder extends ValuesSourceAggregationBuilder
return builder; return builder;
} }
@Override
protected int innerHashCode() {
return 0;
}
@Override
protected boolean innerEquals(Object obj) {
return true;
}
@Override @Override
public String getType() { public String getType() {
return NAME; return NAME;

View File

@ -111,16 +111,6 @@ public class WeightedAvgAggregationBuilder extends MultiValuesSourceAggregationB
return builder; return builder;
} }
@Override
protected int innerHashCode() {
return 0;
}
@Override
protected boolean innerEquals(Object obj) {
return true;
}
@Override @Override
public String getType() { public String getType() {
return NAME; return NAME;

View File

@ -171,32 +171,20 @@ public abstract class AbstractPipelineAggregationBuilder<PAB extends AbstractPip
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(Arrays.hashCode(bucketsPaths), metaData, name, type, doHashCode()); return Objects.hash(Arrays.hashCode(bucketsPaths), metaData, name, type);
} }
protected abstract int doHashCode();
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (obj == null) if (this == obj) return true;
return false; if (obj == null || getClass() != obj.getClass()) return false;
if (getClass() != obj.getClass())
return false;
@SuppressWarnings("unchecked")
AbstractPipelineAggregationBuilder<PAB> other = (AbstractPipelineAggregationBuilder<PAB>) obj; AbstractPipelineAggregationBuilder<PAB> other = (AbstractPipelineAggregationBuilder<PAB>) obj;
if (!Objects.equals(name, other.name)) return Objects.equals(type, other.type)
return false; && Objects.equals(name, other.name)
if (!Objects.equals(type, other.type)) && Objects.equals(metaData, other.metaData)
return false; && Objects.deepEquals(bucketsPaths, other.bucketsPaths);
if (!Objects.deepEquals(bucketsPaths, other.bucketsPaths))
return false;
if (!Objects.equals(metaData, other.metaData))
return false;
return doEquals(obj);
} }
protected abstract boolean doEquals(Object obj);
@Override @Override
public String getType() { public String getType() {
return type; return type;

View File

@ -63,16 +63,6 @@ public class AvgBucketPipelineAggregationBuilder extends BucketMetricsPipelineAg
} }
}; };
@Override
protected int innerHashCode() {
return 0;
}
@Override
protected boolean innerEquals(BucketMetricsPipelineAggregationBuilder<AvgBucketPipelineAggregationBuilder> other) {
return true;
}
@Override @Override
public String getWriteableName() { public String getWriteableName() {
return NAME; return NAME;

View File

@ -147,21 +147,19 @@ public abstract class BucketMetricsPipelineAggregationBuilder<AF extends BucketM
protected abstract XContentBuilder doXContentBody(XContentBuilder builder, Params params) throws IOException; protected abstract XContentBuilder doXContentBody(XContentBuilder builder, Params params) throws IOException;
@Override @Override
protected final int doHashCode() { public int hashCode() {
return Objects.hash(format, gapPolicy, innerHashCode()); return Objects.hash(super.hashCode(), format, gapPolicy);
} }
protected abstract int innerHashCode();
@Override @Override
protected final boolean doEquals(Object obj) { public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
if (super.equals(obj) == false) return false;
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
BucketMetricsPipelineAggregationBuilder<AF> other = (BucketMetricsPipelineAggregationBuilder<AF>) obj; BucketMetricsPipelineAggregationBuilder<AF> other = (BucketMetricsPipelineAggregationBuilder<AF>) obj;
return Objects.equals(format, other.format) return Objects.equals(format, other.format)
&& Objects.equals(gapPolicy, other.gapPolicy) && Objects.equals(gapPolicy, other.gapPolicy);
&& innerEquals(other);
} }
protected abstract boolean innerEquals(BucketMetricsPipelineAggregationBuilder<AF> other);
} }

View File

@ -240,15 +240,20 @@ public class BucketScriptPipelineAggregationBuilder extends AbstractPipelineAggr
} }
@Override @Override
protected int doHashCode() { public int hashCode() {
return Objects.hash(bucketsPathsMap, script, format, gapPolicy); return Objects.hash(super.hashCode(), bucketsPathsMap, script, format, gapPolicy);
} }
@Override @Override
protected boolean doEquals(Object obj) { public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
if (super.equals(obj) == false) return false;
BucketScriptPipelineAggregationBuilder other = (BucketScriptPipelineAggregationBuilder) obj; BucketScriptPipelineAggregationBuilder other = (BucketScriptPipelineAggregationBuilder) obj;
return Objects.equals(bucketsPathsMap, other.bucketsPathsMap) && Objects.equals(script, other.script) return Objects.equals(bucketsPathsMap, other.bucketsPathsMap)
&& Objects.equals(format, other.format) && Objects.equals(gapPolicy, other.gapPolicy); && Objects.equals(script, other.script)
&& Objects.equals(format, other.format)
&& Objects.equals(gapPolicy, other.gapPolicy);
} }
@Override @Override

View File

@ -199,15 +199,20 @@ public class BucketSelectorPipelineAggregationBuilder extends AbstractPipelineAg
} }
@Override @Override
protected int doHashCode() { public int hashCode() {
return Objects.hash(bucketsPathsMap, script, gapPolicy); return Objects.hash(super.hashCode(), bucketsPathsMap, script, gapPolicy);
} }
@Override @Override
protected boolean doEquals(Object obj) { public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
if (super.equals(obj) == false) return false;
BucketSelectorPipelineAggregationBuilder other = (BucketSelectorPipelineAggregationBuilder) obj; BucketSelectorPipelineAggregationBuilder other = (BucketSelectorPipelineAggregationBuilder) obj;
return Objects.equals(bucketsPathsMap, other.bucketsPathsMap) && Objects.equals(script, other.script) return Objects.equals(bucketsPathsMap, other.bucketsPathsMap)
&& Objects.equals(gapPolicy, other.gapPolicy); && Objects.equals(script, other.script)
&& Objects.equals(gapPolicy, other.gapPolicy);
} }
@Override @Override

View File

@ -174,12 +174,15 @@ public class BucketSortPipelineAggregationBuilder extends AbstractPipelineAggreg
} }
@Override @Override
protected int doHashCode() { public int hashCode() {
return Objects.hash(sorts, from, size, gapPolicy); return Objects.hash(super.hashCode(), sorts, from, size, gapPolicy);
} }
@Override @Override
protected boolean doEquals(Object obj) { public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
if (super.equals(obj) == false) return false;
BucketSortPipelineAggregationBuilder other = (BucketSortPipelineAggregationBuilder) obj; BucketSortPipelineAggregationBuilder other = (BucketSortPipelineAggregationBuilder) obj;
return Objects.equals(sorts, other.sorts) return Objects.equals(sorts, other.sorts)
&& Objects.equals(from, other.from) && Objects.equals(from, other.from)

View File

@ -162,12 +162,15 @@ public class CumulativeSumPipelineAggregationBuilder extends AbstractPipelineAgg
} }
@Override @Override
protected int doHashCode() { public int hashCode() {
return Objects.hash(format); return Objects.hash(super.hashCode(), format);
} }
@Override @Override
protected boolean doEquals(Object obj) { public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
if (super.equals(obj) == false) return false;
CumulativeSumPipelineAggregationBuilder other = (CumulativeSumPipelineAggregationBuilder) obj; CumulativeSumPipelineAggregationBuilder other = (CumulativeSumPipelineAggregationBuilder) obj;
return Objects.equals(format, other.format); return Objects.equals(format, other.format);
} }

View File

@ -238,23 +238,19 @@ public class DerivativePipelineAggregationBuilder extends AbstractPipelineAggreg
} }
@Override @Override
protected boolean doEquals(Object obj) { public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
if (super.equals(obj) == false) return false;
DerivativePipelineAggregationBuilder other = (DerivativePipelineAggregationBuilder) obj; DerivativePipelineAggregationBuilder other = (DerivativePipelineAggregationBuilder) obj;
if (!Objects.equals(format, other.format)) { return Objects.equals(format, other.format) &&
return false; gapPolicy == other.gapPolicy &&
} Objects.equals(units, other.units);
if (!Objects.equals(gapPolicy, other.gapPolicy)) {
return false;
}
if (!Objects.equals(units, other.units)) {
return false;
}
return true;
} }
@Override @Override
protected int doHashCode() { public int hashCode() {
return Objects.hash(format, gapPolicy, units); return Objects.hash(super.hashCode(), format, gapPolicy, units);
} }
@Override @Override

View File

@ -97,12 +97,15 @@ public class ExtendedStatsBucketPipelineAggregationBuilder
} }
@Override @Override
protected int innerHashCode() { public int hashCode() {
return Objects.hash(sigma); return Objects.hash(super.hashCode(), sigma);
} }
@Override @Override
protected boolean innerEquals(BucketMetricsPipelineAggregationBuilder<ExtendedStatsBucketPipelineAggregationBuilder> obj) { public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
if (super.equals(obj) == false) return false;
ExtendedStatsBucketPipelineAggregationBuilder other = (ExtendedStatsBucketPipelineAggregationBuilder) obj; ExtendedStatsBucketPipelineAggregationBuilder other = (ExtendedStatsBucketPipelineAggregationBuilder) obj;
return Objects.equals(sigma, other.sigma); return Objects.equals(sigma, other.sigma);
} }

View File

@ -118,12 +118,15 @@ public class InternalBucketMetricValue extends InternalNumericMetricsAggregation
} }
@Override @Override
protected int doHashCode() { public int hashCode() {
return Objects.hash(value, Arrays.hashCode(keys)); return Objects.hash(super.hashCode(), value, Arrays.hashCode(keys));
} }
@Override @Override
protected boolean doEquals(Object obj) { public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
if (super.equals(obj) == false) return false;
InternalBucketMetricValue other = (InternalBucketMetricValue) obj; InternalBucketMetricValue other = (InternalBucketMetricValue) obj;
return Objects.equals(value, other.value) return Objects.equals(value, other.value)
&& Arrays.equals(keys, other.keys); && Arrays.equals(keys, other.keys);

View File

@ -98,12 +98,15 @@ public class InternalDerivative extends InternalSimpleValue implements Derivativ
} }
@Override @Override
protected int doHashCode() { public int hashCode() {
return Objects.hash(normalizationFactor, value); return Objects.hash(super.hashCode(), normalizationFactor, value);
} }
@Override @Override
protected boolean doEquals(Object obj) { public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
if (super.equals(obj) == false) return false;
InternalDerivative other = (InternalDerivative) obj; InternalDerivative other = (InternalDerivative) obj;
return Objects.equals(value, other.value) return Objects.equals(value, other.value)
&& Objects.equals(normalizationFactor, other.normalizationFactor); && Objects.equals(normalizationFactor, other.normalizationFactor);

View File

@ -163,14 +163,18 @@ public class InternalPercentilesBucket extends InternalNumericMetricsAggregation
} }
@Override @Override
protected boolean doEquals(Object obj) { public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
if (super.equals(obj) == false) return false;
InternalPercentilesBucket that = (InternalPercentilesBucket) obj; InternalPercentilesBucket that = (InternalPercentilesBucket) obj;
return Arrays.equals(percents, that.percents) && Arrays.equals(percentiles, that.percentiles); return Arrays.equals(percents, that.percents) && Arrays.equals(percentiles, that.percentiles);
} }
@Override @Override
protected int doHashCode() { public int hashCode() {
return Objects.hash(Arrays.hashCode(percents), Arrays.hashCode(percentiles)); return Objects.hash(super.hashCode(), Arrays.hashCode(percents), Arrays.hashCode(percentiles));
} }
public static class Iter implements Iterator<Percentile> { public static class Iter implements Iterator<Percentile> {

View File

@ -91,12 +91,15 @@ public class InternalSimpleValue extends InternalNumericMetricsAggregation.Singl
} }
@Override @Override
protected int doHashCode() { public int hashCode() {
return Objects.hash(value); return Objects.hash(super.hashCode(), value);
} }
@Override @Override
protected boolean doEquals(Object obj) { public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
if (super.equals(obj) == false) return false;
InternalSimpleValue other = (InternalSimpleValue) obj; InternalSimpleValue other = (InternalSimpleValue) obj;
return Objects.equals(value, other.value); return Objects.equals(value, other.value);
} }

View File

@ -63,16 +63,6 @@ public class MaxBucketPipelineAggregationBuilder extends BucketMetricsPipelineAg
} }
}; };
@Override
protected int innerHashCode() {
return 0;
}
@Override
protected boolean innerEquals(BucketMetricsPipelineAggregationBuilder<MaxBucketPipelineAggregationBuilder> other) {
return true;
}
@Override @Override
public String getWriteableName() { public String getWriteableName() {
return NAME; return NAME;

View File

@ -63,16 +63,6 @@ public class MinBucketPipelineAggregationBuilder extends BucketMetricsPipelineAg
} }
}; };
@Override
protected int innerHashCode() {
return 0;
}
@Override
protected boolean innerEquals(BucketMetricsPipelineAggregationBuilder<MinBucketPipelineAggregationBuilder> other) {
return true;
}
@Override @Override
public String getWriteableName() { public String getWriteableName() {
return NAME; return NAME;

View File

@ -410,12 +410,15 @@ public class MovAvgPipelineAggregationBuilder extends AbstractPipelineAggregatio
} }
@Override @Override
protected int doHashCode() { public int hashCode() {
return Objects.hash(format, gapPolicy, window, model, predict, minimize); return Objects.hash(super.hashCode(), format, gapPolicy, window, model, predict, minimize);
} }
@Override @Override
protected boolean doEquals(Object obj) { public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
if (super.equals(obj) == false) return false;
MovAvgPipelineAggregationBuilder other = (MovAvgPipelineAggregationBuilder) obj; MovAvgPipelineAggregationBuilder other = (MovAvgPipelineAggregationBuilder) obj;
return Objects.equals(format, other.format) return Objects.equals(format, other.format)
&& Objects.equals(gapPolicy, other.gapPolicy) && Objects.equals(gapPolicy, other.gapPolicy)

View File

@ -224,12 +224,15 @@ public class MovFnPipelineAggregationBuilder extends AbstractPipelineAggregation
} }
@Override @Override
protected int doHashCode() { public int hashCode() {
return Objects.hash(bucketsPathString, script, format, gapPolicy, window); return Objects.hash(super.hashCode(), bucketsPathString, script, format, gapPolicy, window);
} }
@Override @Override
protected boolean doEquals(Object obj) { public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
if (super.equals(obj) == false) return false;
MovFnPipelineAggregationBuilder other = (MovFnPipelineAggregationBuilder) obj; MovFnPipelineAggregationBuilder other = (MovFnPipelineAggregationBuilder) obj;
return Objects.equals(bucketsPathString, other.bucketsPathString) return Objects.equals(bucketsPathString, other.bucketsPathString)
&& Objects.equals(script, other.script) && Objects.equals(script, other.script)

View File

@ -180,14 +180,18 @@ public class PercentilesBucketPipelineAggregationBuilder
}; };
@Override @Override
protected int innerHashCode() { public int hashCode() {
return Objects.hash(Arrays.hashCode(percents), keyed); return Objects.hash(super.hashCode(), Arrays.hashCode(percents), keyed);
} }
@Override @Override
protected boolean innerEquals(BucketMetricsPipelineAggregationBuilder<PercentilesBucketPipelineAggregationBuilder> obj) { public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
if (super.equals(obj) == false) return false;
PercentilesBucketPipelineAggregationBuilder other = (PercentilesBucketPipelineAggregationBuilder) obj; PercentilesBucketPipelineAggregationBuilder other = (PercentilesBucketPipelineAggregationBuilder) obj;
return Objects.deepEquals(percents, other.percents) && Objects.equals(keyed, other.keyed); return Objects.deepEquals(percents, other.percents)
&& Objects.equals(keyed, other.keyed);
} }
@Override @Override

View File

@ -228,11 +228,15 @@ public class SerialDiffPipelineAggregationBuilder extends AbstractPipelineAggreg
} }
@Override @Override
protected int doHashCode() { public int hashCode() {
return Objects.hash(format, gapPolicy, lag); return Objects.hash(super.hashCode(), format, gapPolicy, lag);
} }
@Override @Override
protected boolean doEquals(Object obj) { public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
if (super.equals(obj) == false) return false;
SerialDiffPipelineAggregationBuilder other = (SerialDiffPipelineAggregationBuilder) obj; SerialDiffPipelineAggregationBuilder other = (SerialDiffPipelineAggregationBuilder) obj;
return Objects.equals(format, other.format) return Objects.equals(format, other.format)
&& Objects.equals(gapPolicy, other.gapPolicy) && Objects.equals(gapPolicy, other.gapPolicy)

View File

@ -64,16 +64,6 @@ public class StatsBucketPipelineAggregationBuilder extends BucketMetricsPipeline
} }
}; };
@Override
protected int innerHashCode() {
return 0;
}
@Override
protected boolean innerEquals(BucketMetricsPipelineAggregationBuilder<StatsBucketPipelineAggregationBuilder> other) {
return true;
}
@Override @Override
public String getWriteableName() { public String getWriteableName() {
return NAME; return NAME;

View File

@ -63,16 +63,6 @@ public class SumBucketPipelineAggregationBuilder extends BucketMetricsPipelineAg
} }
}; };
@Override
protected int innerHashCode() {
return 0;
}
@Override
protected boolean innerEquals(BucketMetricsPipelineAggregationBuilder<SumBucketPipelineAggregationBuilder> other) {
return true;
}
@Override @Override
public String getWriteableName() { public String getWriteableName() {
return NAME; return NAME;

Some files were not shown because too many files have changed in this diff Show More