com.jdroid.java.utils.ObjectUtils Maven / Gradle / Ivy
package com.jdroid.java.utils;
/**
*
* Operations on Object
.
*
*/
public class ObjectUtils {
/**
*
* Compares two objects for equality, where either one or both objects may be null
.
*
*
*
* ObjectUtils.equals(null, null) = true
* ObjectUtils.equals(null, "") = false
* ObjectUtils.equals("", null) = false
* ObjectUtils.equals("", "") = true
* ObjectUtils.equals(Boolean.TRUE, null) = false
* ObjectUtils.equals(Boolean.TRUE, "true") = false
* ObjectUtils.equals(Boolean.TRUE, Boolean.TRUE) = true
* ObjectUtils.equals(Boolean.TRUE, Boolean.FALSE) = false
*
*
* @param object1 the first object, may be null
* @param object2 the second object, may be null
* @return true
if the values of both objects are the same
*/
public static boolean equals(Object object1, Object object2) {
if (object1 == object2) {
return true;
}
if ((object1 == null) || (object2 == null)) {
return false;
}
return object1.equals(object2);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy