
net.sf.jagg.model.PartitionClause Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jagg-core Show documentation
Show all versions of jagg-core Show documentation
jAgg is a Java 5.0 API that supports “group by” operations on Lists of Java objects: aggregate operations such as count, sum, max, min, avg, and many more. It also allows custom aggregate operations.
The newest version!
package net.sf.jagg.model;
import java.util.List;
/**
* A PartitionClause
represents how to partition data for
* analytic function processing. It works like an SQL "group by" clause. No
* data in one partition will affect the processing of another partition.
*
* @author Randy Gettman
* @since 0.9.0
*/
public class PartitionClause
{
private List myProperties;
/**
* Constructs a PartitionClause
that consists of a
* List
of string properties.
* @param properties A List
of string properties.
*/
public PartitionClause(List properties)
{
myProperties = properties;
}
/**
* Returns the List
of string properties.
* @return The List
of string properties.
*/
public List getProperties()
{
return myProperties;
}
/**
* For equality, all properties must match, including the count of
* properties.
* @param obj Another object, hopefully a PartitionClause
.
* @return true
if the properties are equal in number and to
* themselves, in order, else false
.
*/
public boolean equals(Object obj)
{
if (obj != null && obj instanceof PartitionClause)
{
PartitionClause pc = (PartitionClause) obj;
if (myProperties.size() != pc.myProperties.size())
return false;
for (int i = 0; i < myProperties.size(); i++)
{
if (!myProperties.get(i).equals(pc.myProperties.get(i)))
return false;
}
return true;
}
return false;
}
/**
* Returns a hash code.
* @return A hash code.
*/
public int hashCode()
{
int hc = 0;
for (String prop : myProperties)
{
hc = 31 * hc + prop.hashCode();
}
return hc;
}
/**
* Returns the string representation.
* @return The string representation.
*/
public String toString()
{
StringBuilder buf = new StringBuilder();
buf.append("partitionBy(");
for (int i = 0; i < myProperties.size(); i++)
{
if (i != 0)
buf.append(", ");
buf.append(myProperties.get(i));
}
buf.append(")");
return buf.toString();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy