public static Class<?> mostSpecificClass(Class<?> classOne,
                                             Class<?> classTwo)
    {
        if (classOne.isAssignableFrom(classTwo)) {
            return classTwo; // d479669
        }
        else if (classTwo.isAssignableFrom(classOne)) {
            return classOne; // d479669
        }

        return null;
    }
public static Class < ? > mostSpecificClass ( Class < ? > classOne , Class < ? > classTwo ) { if ( classOne . isAssignableFrom ( classTwo ) ) { return classTwo ; } else if ( classTwo . isAssignableFrom ( classOne ) ) { return classOne ; } return null ; }
Returns the most most specific class to the caller. If the two
classes are not compatible a null is returned.

@param classOne Class type of the method or field
@param classTwo Class type of object being injected