org.kuali.rice.kns.util
Class BeanPropertyComparator

java.lang.Object
  extended by org.kuali.rice.kns.util.BeanPropertyComparator
All Implemented Interfaces:
Serializable, Comparator

public class BeanPropertyComparator
extends Object
implements Comparator, Serializable

This class compares the two beans using multiple property names.

See Also:
Serialized Form

Nested Class Summary
static class BeanPropertyComparator.BeanComparisonException
           
 
Field Summary
private  Comparator booleanComparator
           
private  Comparator genericComparator
           
(package private)  boolean ignoreCase
           
private  List propertyNames
           
private static long serialVersionUID
           
private  Comparator stringComparator
           
 
Constructor Summary
BeanPropertyComparator(List propertyNames)
          Constructs a PropertyComparator for comparing beans using the properties named in the given List; if the List is null, the beans will be compared directly (by Properties will be compared in the order in which they are listed.
BeanPropertyComparator(List propertyNames, boolean ignoreCase)
          Constructs a PropertyComparator for comparing beans using the properties named in the given List.
 
Method Summary
 int compare(Object o1, Object o2)
          Compare two JavaBeans by the properties given to the constructor.
 
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
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

ignoreCase

boolean ignoreCase

propertyNames

private List propertyNames

stringComparator

private Comparator stringComparator

booleanComparator

private Comparator booleanComparator

genericComparator

private Comparator genericComparator
Constructor Detail

BeanPropertyComparator

public BeanPropertyComparator(List propertyNames)
Constructs a PropertyComparator for comparing beans using the properties named in the given List; if the List is null, the beans will be compared directly (by Properties will be compared in the order in which they are listed. Case will be ignored in String comparisons.

Parameters:
propertyNames - List of property names (as Strings) used to compare beans

BeanPropertyComparator

public BeanPropertyComparator(List propertyNames,
                              boolean ignoreCase)
Constructs a PropertyComparator for comparing beans using the properties named in the given List. Properties will be compared in the order in which they are listed. Case will be ignored if ignoreCase is true.

Parameters:
propertyNames - List of property names (as Strings) used to compare beans
ignoreCase - if true, case will be ignored during String comparisons
Method Detail

compare

public int compare(Object o1,
                   Object o2)
Compare two JavaBeans by the properties given to the constructor. If no propertues

Specified by:
compare in interface Comparator
Parameters:
o1 - Object The first bean to get data from to compare against
o2 - Object The second bean to get data from to compare
Returns:
int negative or positive based on order


Copyright © 2004-2011 The Kuali Foundation. All Rights Reserved.