net.sf.jett.util
Class GroupOrderByComparator<T extends Group>

java.lang.Object
  extended by net.sf.jett.util.GroupOrderByComparator<T>
All Implemented Interfaces:
java.util.Comparator<T>

public class GroupOrderByComparator<T extends Group>
extends java.lang.Object
implements java.util.Comparator<T>

A GroupOrderByComparator is an OrderByComparator that operates on groups and understands that some of the "order by" properties are group properties (these must all be before the other "order by" properties that aren't group properties).

Since:
0.3.0
Author:
Randy Gettman

Constructor Summary
GroupOrderByComparator(OrderByComparator<java.lang.Object> orderByComparator, java.util.List<java.lang.String> groupByProperties)
          Constructs a GroupOrderByComparator that operates on the given List of "order by" expressions, and assumes that the Groups are grouped by the given List of "group by" expressions.
 
Method Summary
 int compare(T g1, T g2)
          Compares the given Groups to determine order.
 java.util.List<java.lang.String> getGroupByProperties()
          Returns the List of "group by" properties.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Comparator
equals
 

Constructor Detail

GroupOrderByComparator

public GroupOrderByComparator(OrderByComparator<java.lang.Object> orderByComparator,
                              java.util.List<java.lang.String> groupByProperties)
Constructs a GroupOrderByComparator that operates on the given List of "order by" expressions, and assumes that the Groups are grouped by the given List of "group by" expressions.

Parameters:
orderByComparator - An OrderByComparator.
groupByProperties - A List of "group by" properties.
Throws:
ParseException - If there is a problem parsing the expressions, or if any "group by" properties are preceded in the "order by" properties by other properties that are not "group by" properties.
Method Detail

compare

public int compare(T g1,
                   T g2)

Compares the given Groups to determine order. Fulfills the Comparator contract by returning a negative integer, 0, or a positive integer if o1 is less than, equal to, or greater than o2.

This compare method compares the group's representative objects.

Specified by:
compare in interface java.util.Comparator<T extends Group>
Parameters:
g1 - The left-hand-side Group to compare.
g2 - The right-hand-side Group to compare.
Returns:
A negative integer, 0, or a positive integer if g1 is less than, equal to, or greater than g2.
Throws:
java.lang.UnsupportedOperationException - If any property specified in the constructor doesn't correspond to a no-argument "get<Property>" getter method in T, or if the property's type is not Comparable.

getGroupByProperties

public java.util.List<java.lang.String> getGroupByProperties()
Returns the List of "group by" properties.

Returns:
The List of "group by" properties.


Copyright © 2012-2013 Jett Team. All Rights Reserved.