class BeanPropertyComparator implements Comparator, Serializable {

    public int compare(Object o1, Object o2) {
        int compared = 0;

        try {
            for (Iterator i = propertyNames.iterator(); (compared == 0) && i.hasNext();) {
                String currentProperty = i.next().toString();

                // choose appropriate comparator
                Comparator currentComparator = null;
                try {
                    PropertyDescriptor propertyDescriptor = PropertyUtils.getPropertyDescriptor(o1, currentProperty);
                    Class propertyClass = propertyDescriptor.getPropertyType();
                    if (propertyClass.equals(String.class)) {
                        currentComparator = this.stringComparator;
                    }
                    else if (TypeUtils.isBooleanClass(propertyClass)) {
                        currentComparator = this.booleanComparator;
                    }
                    else {
                        currentComparator = this.genericComparator;
                    }
                }
                catch (NullPointerException e) {
                    throw new BeanComparisonException("unable to find property '" + o1.getClass().getName() + "." + currentProperty + "'", e);
                }

                // compare the values
                Object value1 = PropertyUtils.getProperty(o1, currentProperty);
                Object value2 = PropertyUtils.getProperty(o2, currentProperty);
                /* Fix for KULRICE-5170 : BeanPropertyComparator throws exception when a null value is found in sortable non-string data type column */
                if ( value1 == null && value2 == null)
                    return 0;
                else if ( value1 == null)
                    return -1;
                else if ( value2 == null )
                    return 1;
                /* End KULRICE-5170 Fix*/
                compared = currentComparator.compare(value1, value2);
            }
        }
        catch (IllegalAccessException e) {
            throw new BeanComparisonException("unable to compare property values", e);
        }
        catch (NoSuchMethodException e) {
            throw new BeanComparisonException("unable to compare property values", e);
        }
        catch (InvocationTargetException e) {
            throw new BeanComparisonException("unable to compare property values", e);
        }

        return compared;
    }

    public  BeanPropertyComparator(List propertyNames);
    public  BeanPropertyComparator(List propertyNames, boolean ignoreCase);

}