Here you can find the source of areEqual(Object value1, Object value2)
Parameter | Description |
---|---|
value1 | First value. |
value2 | Second value. |
public static boolean areEqual(Object value1, Object value2)
//package com.java2s; public class Main { /**//from w w w. ja v a 2 s . c o m * Compares the two given values by taking null and NaN values into account.<br>Two null values will be considered * equal. Two NaN values (either Double or Float) will be considered equal. * * @param value1 First value. * @param value2 Second value. * * @return True if both values are equal or if both are null. */ public static boolean areEqual(Object value1, Object value2) { return ((value1 == null) && (value2 == null)) || (isNaN(value1) && isNaN(value2)) || ((value1 != null) && value1.equals(value2)); } /** * Checks if the specified value is either NaN. * * @param value Value to be checked. * * @return True if the value is NaN, false otherwise. */ private static boolean isNaN(Object value) { return ((value instanceof Float) && Float.isNaN((Float) value)) || ((value instanceof Double) && Double.isNaN((Double) value)); } }