public static int reflectionCompare(
        Object lhs, 
        Object rhs, 
        boolean compareTransients, 
        Class<?> reflectUpToClass, 
        String... excludeFields) {

        if (lhs == rhs) {
            return 0;
        }
        if (lhs == null || rhs == null) {
            throw new NullPointerException();
        }
        Class<?> lhsClazz = lhs.getClass();
        if (!lhsClazz.isInstance(rhs)) {
            throw new ClassCastException();
        }
        CompareToBuilder compareToBuilder = new CompareToBuilder();
        reflectionAppend(lhs, rhs, lhsClazz, compareToBuilder, compareTransients, excludeFields);
        while (lhsClazz.getSuperclass() != null && lhsClazz != reflectUpToClass) {
            lhsClazz = lhsClazz.getSuperclass();
            reflectionAppend(lhs, rhs, lhsClazz, compareToBuilder, compareTransients, excludeFields);
        }
        return compareToBuilder.toComparison();
    }
<p>Compares two <code>Object</code>s via reflection.</p>

<p>Fields can be private, thus <code>AccessibleObject.setAccessible</code>
is used to bypass normal access control checks. This will fail under a 
security manager unless the appropriate permissions are set.</p>

<ul>
<li>Static fields will not be compared</li>
<li>If the <code>compareTransients</code> is <code>true</code>,
    compares transient members.  Otherwise ignores them, as they
    are likely derived fields.</li>
<li>Compares superclass fields up to and including <code>reflectUpToClass</code>.
    If <code>reflectUpToClass</code> is <code>null</code>, compares all superclass fields.</li>
</ul>

<p>If both <code>lhs</code> and <code>rhs</code> are <code>null</code>,
they are considered equal.</p>

@param lhs  left-hand object
@param rhs  right-hand object
@param compareTransients  whether to compare transient fields
@param reflectUpToClass  last superclass for which fields are compared
@param excludeFields  fields to exclude
@return a negative integer, zero, or a positive integer as <code>lhs</code>
 is less than, equal to, or greater than <code>rhs</code>
@throws NullPointerException  if either <code>lhs</code> or <code>rhs</code>
 (but not both) is <code>null</code>
@throws ClassCastException  if <code>rhs</code> is not assignment-compatible
 with <code>lhs</code>
@since 2.2 (2.0 as <code>reflectionCompare(Object, Object, boolean, Class)</code>)
android/android_framework/base/src/main/java/lang3/builder/CompareToBuilder.java