ReflectTools implements Serializable { public static Class<?> findCommonBaseType(Class<?> a, Class<?> b) { if (a.isInterface()) { throw new IllegalArgumentException("a cannot be an interface"); } if (b.isInterface()) { throw new IllegalArgumentException("b cannot be an interface"); } if (a.isPrimitive()) { throw new IllegalArgumentException("a cannot be a primitive type"); } if (b.isPrimitive()) { throw new IllegalArgumentException("b cannot be a primitive type"); } if (a.isAssignableFrom(b)) { return a; } else if (b.isAssignableFrom(a)) { return b; } Class<?> currentClass = a; while (!currentClass.isAssignableFrom(b)) { currentClass = currentClass.getSuperclass(); } return currentClass; }  static Method findMethod(Class<?> cls, String methodName,
            Class<?>... parameterTypes); static Object getJavaFieldValue(Object object,
            java.lang.reflect.Field field); static Object getJavaFieldValue(Object object,
            java.lang.reflect.Field field, Class<?> propertyType); static void setJavaFieldValue(Object object,
            java.lang.reflect.Field field, Object value); static Class<?> convertPrimitiveType(Class<?> type); static Serializable getPrimitiveDefaultValue(
            Class<?> primitiveType); static boolean isSetter(Method method); static boolean isSetterName(String methodName); static boolean isGetterName(String methodName, boolean isBoolean); static boolean isGetter(Method method); static Stream<Method> getGetterMethods(Class<?> type); static Stream<Method> getSetterMethods(Class<?> type); static boolean isNotObjectMethod(Method method); static String getPropertyName(Method method); static Type getPropertyType(Method method); static T createInstance(Class<T> cls); static T createProxyInstance(Class<T> proxyClass,
            Class<?> originalClass); static void checkClassAccessibility(Class<?> clazz); static Type createParameterizedType(Class<?> rawType, Type subType); static Class<?> getGenericInterfaceType(Class<?> clazz,
            Class<?> interfaceType); static Optional<Method> getGetter(Class<? extends Object> beanClass,
            String propertyName); static boolean isCheckedException(Class<?> exceptionClass); static Method getFunctionalMethod(Class<?> functionalClass); static List<Integer> getConstantIntValues(Class<?> clazz); static Class<?> findCommonBaseType(Class<?> a, Class<?> b); static Optional<ClassLoader> findClosestCommonClassLoaderAncestor(
            ClassLoader classLoaderA, ClassLoader classLoaderB); static boolean hasAnnotation(AnnotatedElement element,
            String annotationFqn); static Object getAnnotationMethodValue(Annotation annotation,
            String methodName); static Optional<Annotation> getAnnotation(AnnotatedElement element,
            String annotationFqn);  }
@Test public void findCommonBaseType_sameType() { assertSame(Number.class, ReflectTools.findCommonBaseType(Number.class, Number.class)); }
@Test public void findCommonBaseType_aExtendsB() { assertSame(Number.class, ReflectTools.findCommonBaseType(Integer.class, Number.class)); }
@Test public void findCommonBaseType_bExtendsA() { assertSame(Number.class, ReflectTools.findCommonBaseType(Number.class, Integer.class)); }
@Test public void findCommonBaseType_commonBase() { assertSame(Number.class, ReflectTools.findCommonBaseType(Double.class, Integer.class)); }
@Test public void findCommonBaseType_noCommonBase() { assertSame(Object.class, ReflectTools.findCommonBaseType(String.class, Number.class)); }
@Test public void findCommonBaseType_interfaceNotSupported() { thrown.expect(IllegalArgumentException.class); thrown.expectMessage("a cannot be an interface"); ReflectTools.findCommonBaseType(Comparable.class, Object.class); }
@Test public void findCommonBaseType_primitiveNotSupported() { thrown.expect(IllegalArgumentException.class); thrown.expectMessage("a cannot be a primitive type"); ReflectTools.findCommonBaseType(int.class, Object.class); }