This makes sure the class is setup as the principal class for the framework so that code in the finishInitialization() gets called.
/**
* This class in installed from within framework principal's finishInitialization().
* See build.properties to find out the name of the principal class.
*
* This class makes sure that nulls are treated as greater than non-null values
* in order to be congruent with ORACLE's sorting behavior.
*
* If you want to disable this behavior set property NullsAtEnd to false explicitly.
*
* @author ricardo
*
*/
public class NullsAtEndComparisonSupport extends EOSortOrdering.ComparisonSupport {
private static final int NONE_NULL = -42;
/**
* Returns NONE_NULL when left and right are both non-null. Otherwise
* returns -1, 0 or 1 to achieve the null > non-null effect.
*/
private static int _handleNulls(Object left, Object right)
{
if (ERXValueUtilities.isNull(left)) {
return !ERXValueUtilities.isNull(right) ? 1 : 0;
} else {
return !ERXValueUtilities.isNull(right) ? NONE_NULL : -1;
}
}
/** Overrides super class implementation so that null > non-null */
protected int _genericCompareTo(Object left, Object right)
{
int nullCheck = _handleNulls(left, right);
if (nullCheck != NONE_NULL) {
return nullCheck;
}
// For none null values the behavior is as before so let the
// super class handle it.
return super._genericCompareTo(left, right);
}
/** Overrides super class implementation so that null > non-null */
protected int _genericCaseInsensitiveCompareTo(Object left, Object right)
{
int nullCheck = _handleNulls(left, right);
if (nullCheck != NONE_NULL) {
return nullCheck;
}
// For none null values the behavior is as before so let the
// super class handle it.
return super._genericCaseInsensitiveCompareTo(left, right);
}
}