net.sf.jagg
Class AggregateValuePropertiesComparator<T>

java.lang.Object
  extended by net.sf.jagg.AggregateValuePropertiesComparator<T>
All Implemented Interfaces:
java.util.Comparator<AggregateValue<T>>

public class AggregateValuePropertiesComparator<T>
extends java.lang.Object
implements java.util.Comparator<AggregateValue<T>>

This class represents a Comparator that is capable of comparing two objects based on a dynamic list of properties of the objects of type T. These objects are wrapped in AggregateValues. This class is used internally by Aggregation objects to sort a List<AggregateValue<T>> according to a specified list of properties.

Since:
0.7.0
Author:
Randy Gettman

Constructor Summary
AggregateValuePropertiesComparator(java.util.List<java.lang.String> properties)
          Construct an AggregateValuePropertiesComparator that pays attention to the given List of properties in an AggregateValue<T>.
 
Method Summary
 int compare(AggregateValue<T> av1, AggregateValue<T> av2)
          Compares the given objects to determine order.
 boolean equals(java.lang.Object obj)
          Indicates whether the given AggregateValuePropertiesComparator is equal to this AggregateValuePropertiesComparator.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AggregateValuePropertiesComparator

public AggregateValuePropertiesComparator(java.util.List<java.lang.String> properties)
Construct an AggregateValuePropertiesComparator that pays attention to the given List of properties in an AggregateValue<T>. All properties must be Comparable.

Parameters:
properties - A List<String> of properties.
Method Detail

compare

public int compare(AggregateValue<T> av1,
                   AggregateValue<T> av2)
            throws java.lang.UnsupportedOperationException

Compares the given objects 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.

Null property values compare equal to each other, and a null property compares greater than a non-null property

.

Specified by:
compare in interface java.util.Comparator<AggregateValue<T>>
Parameters:
av1 - The left-hand-side object to compare.
av2 - The right-hand-side object to compare.
Returns:
A negative integer, 0, or a positive integer if o1 is less than, equal to, or greater than o2.
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.

equals

public boolean equals(java.lang.Object obj)
Indicates whether the given AggregateValuePropertiesComparator is equal to this AggregateValuePropertiesComparator. All property names must match in order.

Specified by:
equals in interface java.util.Comparator<AggregateValue<T>>
Overrides:
equals in class java.lang.Object
Parameters:
obj - The other AggregateValuePropertiesComparator.


Copyright © 2010-2013 jAgg Team. All Rights Reserved.