Skip to content
Snippets Groups Projects
Commit 8b9dfa27 authored by ribeaudc's avatar ribeaudc
Browse files

[LMS-654] fix: - Unit tests in 'lims' project.

change: - Improve error message in 'EqualsHashUtils'.

SVN: 9089
parent 0ca429e2
No related branches found
No related tags found
No related merge requests found
...@@ -16,21 +16,30 @@ ...@@ -16,21 +16,30 @@
package ch.systemsx.cisd.openbis.generic.shared.util; package ch.systemsx.cisd.openbis.generic.shared.util;
import ch.systemsx.cisd.common.utilities.MethodUtils;
/** /**
* Utility class containing methods useful in defining equals and hashCode methods. * Utility class containing methods useful in defining equals and hashCode methods.
* *
* @author Izabela Adamczyk * @author Izabela Adamczyk
*/ */
public class EqualsHashUtils public final class EqualsHashUtils
{ {
private EqualsHashUtils()
{
// Can not be instantiated.
}
public static void assertDefined(final Object o, final String name) public static void assertDefined(final Object o, final String name)
{ {
assert name != null : "Unspecified name.";
if (o == null) if (o == null)
{ {
throw new IllegalStateException("Field should be defined but is null: " + name final String className =
+ ". Equals operation cannot be performed."); MethodUtils.getMethodOnStack(2).getDeclaringClass().getSimpleName();
throw new IllegalStateException(String.format(
"Field name '%s' in class '%s' should be defined but is null."
+ " Equals operation cannot be performed.", name, className));
} }
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment