org.molgenis.data.support.AggregateQueryImpl Maven / Gradle / Ivy
package org.molgenis.data.support;
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
import org.molgenis.data.Entity;
import org.molgenis.data.Query;
import org.molgenis.data.aggregation.AggregateQuery;
import org.molgenis.data.meta.model.Attribute;
public class AggregateQueryImpl implements AggregateQuery {
private Attribute attrX;
private Attribute attrY;
private Attribute attrDistinct;
private Query q;
public AggregateQueryImpl() {}
public AggregateQueryImpl(
Attribute attrX, Attribute attrY, Attribute attrDistinct, Query q) {
this.attrX = attrX;
this.attrY = attrY;
this.attrDistinct = attrDistinct;
this.q = q;
}
public AggregateQueryImpl attrX(Attribute attrX) {
this.attrX = attrX;
return this;
}
public AggregateQueryImpl attrY(Attribute attrY) {
this.attrY = attrY;
return this;
}
public AggregateQueryImpl attrDistinct(Attribute attrDistinct) {
this.attrDistinct = attrDistinct;
return this;
}
public AggregateQueryImpl query(Query q) {
this.q = q;
return this;
}
public void setAttributeX(Attribute attrX) {
this.attrX = attrX;
}
public void setAttributeY(Attribute attrY) {
this.attrY = attrY;
}
public void setAttributeDistinct(Attribute attrDistinct) {
this.attrDistinct = attrDistinct;
}
public void setQuery(Query q) {
this.q = q;
}
@Nullable
@CheckForNull
@Override
public Query getQuery() {
return q;
}
@Nullable
@CheckForNull
@Override
public Attribute getAttributeX() {
return attrX;
}
@Nullable
@CheckForNull
@Override
public Attribute getAttributeY() {
return attrY;
}
@Nullable
@CheckForNull
@Override
public Attribute getAttributeDistinct() {
return attrDistinct;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((attrDistinct == null) ? 0 : attrDistinct.hashCode());
result = prime * result + ((attrX == null) ? 0 : attrX.hashCode());
result = prime * result + ((attrY == null) ? 0 : attrY.hashCode());
result = prime * result + ((q == null) ? 0 : q.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null) return false;
if (getClass() != obj.getClass()) return false;
AggregateQueryImpl other = (AggregateQueryImpl) obj;
if (attrDistinct == null) {
if (other.attrDistinct != null) return false;
} else if (!attrDistinct.equals(other.attrDistinct)) return false;
if (attrX == null) {
if (other.attrX != null) return false;
} else if (!attrX.equals(other.attrX)) return false;
if (attrY == null) {
if (other.attrY != null) return false;
} else if (!attrY.equals(other.attrY)) return false;
if (q == null) {
if (other.q != null) return false;
} else if (!q.equals(other.q)) return false;
return true;
}
}