All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.kuali.common.util.ObjectUtils Maven / Gradle / Ivy

There is a newer version: 4.4.17
Show newest version
package org.kuali.common.util;

public class ObjectUtils {

	/**
	 * 

* This method returns true if the toString() methods on both objects return matching strings AND both objects are the exact same runtime type. *

* *

* Returns true immediately if main==other (ie they are the same object). *

* *

* Returns false immediately if other==null or is a different runtime type than main. *

* *

* If neither one is null, and both are the exact same runtime type, then compare the toString() methods *

* * @param main * The object other is being compared to. * @param other * The object being examined for equality with main. * * @throws NullPointerException * If main is null or main.toString() returns null */ public static boolean equalsByToString(Object main, Object other) { // Main can't be null if (main == null) { throw new NullPointerException("main is null"); } // They are the same object if (main == other) { return true; } // Only bother comparing the toString() methods if they are the exact same runtime type if (other != null && main.getClass() == other.getClass()) { return main.toString().equals(other.toString()); } else { return false; } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy