@Test void testExplicitlyUnequal_OverridesEqualsMethod() { assertFalse(explicitlyUnequal(Collections.singletonList("value"), Collections.singletonList("value"))); assertTrue(explicitlyUnequal(Collections.singletonList("value1"), Collections.singletonList("value"))); }
@SuppressWarnings("unchecked") public static boolean explicitlyUnequal(Object value, Object otherValue) { if (value == otherValue) { return false; } else if (value == null || otherValue == null) { return true; } else if (value instanceof Comparable) { return ((Comparable) value).compareTo(otherValue) != 0; } else if (hasEqualsMethod(value.getClass())) { return !value.equals(otherValue); } return false; }
ReflectionUtils { @SuppressWarnings("unchecked") public static boolean explicitlyUnequal(Object value, Object otherValue) { if (value == otherValue) { return false; } else if (value == null || otherValue == null) { return true; } else if (value instanceof Comparable) { return ((Comparable) value).compareTo(otherValue) != 0; } else if (hasEqualsMethod(value.getClass())) { return !value.equals(otherValue); } return false; } }
ReflectionUtils { @SuppressWarnings("unchecked") public static boolean explicitlyUnequal(Object value, Object otherValue) { if (value == otherValue) { return false; } else if (value == null || otherValue == null) { return true; } else if (value instanceof Comparable) { return ((Comparable) value).compareTo(otherValue) != 0; } else if (hasEqualsMethod(value.getClass())) { return !value.equals(otherValue); } return false; } private  ReflectionUtils(); }
ReflectionUtils { @SuppressWarnings("unchecked") public static boolean explicitlyUnequal(Object value, Object otherValue) { if (value == otherValue) { return false; } else if (value == null || otherValue == null) { return true; } else if (value instanceof Comparable) { return ((Comparable) value).compareTo(otherValue) != 0; } else if (hasEqualsMethod(value.getClass())) { return !value.equals(otherValue); } return false; } private  ReflectionUtils(); @SuppressWarnings("unchecked") static R getFieldValue(Field field, Object object); static void setFieldValue(Field field, Object object, T value); static Class<?> declaringClass(Class<?> instanceClass, String methodName, Class<?>... parameterTypes); static boolean hasEqualsMethod(Class<?> type); @SuppressWarnings("unchecked") static boolean explicitlyUnequal(Object value, Object otherValue); static T ensureAccessible(T member); static boolean isAccessible(AccessibleObject member); static boolean isNonFinalPublicMember(Member member); static Iterable<Field> fieldsOf(Class<?> clazz); static Method methodOf(Class<?> clazz, String methodName, Class<?>... parameterTypes); static Iterable<Method> methodsOf(Class<?> clazz); static Class<?> resolvePrimitiveWrapperType(Class<?> primitiveType); static Type resolvePrimitiveWrapperTypeIfPrimitive(Type type); static Type unwrapIfType(Type type, Class<?>... wrapperTypes); static boolean isTransient(Field field); static Optional<Class<?>> resolveGenericType(Field field, int genericTypeIndex); static Optional<Class<?>> resolveMemberGenericType(Member member, int genericTypeIndex); @SuppressWarnings("unchecked") static R invokeAndGetMethodValue(Method method, Object object); @SuppressWarnings("unchecked") static R getMemberValue(Member member, Object target); static Class<?> getMemberValueType(Member member); static Type getMemberGenericType(Member member); static String getMemberGenericString(Member member); }
ReflectionUtils { @SuppressWarnings("unchecked") public static boolean explicitlyUnequal(Object value, Object otherValue) { if (value == otherValue) { return false; } else if (value == null || otherValue == null) { return true; } else if (value instanceof Comparable) { return ((Comparable) value).compareTo(otherValue) != 0; } else if (hasEqualsMethod(value.getClass())) { return !value.equals(otherValue); } return false; } private  ReflectionUtils(); @SuppressWarnings("unchecked") static R getFieldValue(Field field, Object object); static void setFieldValue(Field field, Object object, T value); static Class<?> declaringClass(Class<?> instanceClass, String methodName, Class<?>... parameterTypes); static boolean hasEqualsMethod(Class<?> type); @SuppressWarnings("unchecked") static boolean explicitlyUnequal(Object value, Object otherValue); static T ensureAccessible(T member); static boolean isAccessible(AccessibleObject member); static boolean isNonFinalPublicMember(Member member); static Iterable<Field> fieldsOf(Class<?> clazz); static Method methodOf(Class<?> clazz, String methodName, Class<?>... parameterTypes); static Iterable<Method> methodsOf(Class<?> clazz); static Class<?> resolvePrimitiveWrapperType(Class<?> primitiveType); static Type resolvePrimitiveWrapperTypeIfPrimitive(Type type); static Type unwrapIfType(Type type, Class<?>... wrapperTypes); static boolean isTransient(Field field); static Optional<Class<?>> resolveGenericType(Field field, int genericTypeIndex); static Optional<Class<?>> resolveMemberGenericType(Member member, int genericTypeIndex); @SuppressWarnings("unchecked") static R invokeAndGetMethodValue(Method method, Object object); @SuppressWarnings("unchecked") static R getMemberValue(Member member, Object target); static Class<?> getMemberValueType(Member member); static Type getMemberGenericType(Member member); static String getMemberGenericString(Member member);  }