From 8b9dfa2734695d028c8b23f1c4ddfbdee887af50 Mon Sep 17 00:00:00 2001 From: ribeaudc <ribeaudc> Date: Tue, 25 Nov 2008 10:11:25 +0000 Subject: [PATCH] [LMS-654] fix: - Unit tests in 'lims' project. change: - Improve error message in 'EqualsHashUtils'. SVN: 9089 --- .../generic/shared/util/EqualsHashUtils.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/util/EqualsHashUtils.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/util/EqualsHashUtils.java index 8582cb7976a..b6da1ba4df6 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/util/EqualsHashUtils.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/util/EqualsHashUtils.java @@ -16,21 +16,30 @@ 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. * * @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) { + assert name != null : "Unspecified name."; if (o == null) { - throw new IllegalStateException("Field should be defined but is null: " + name - + ". Equals operation cannot be performed."); + final String className = + 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)); } } - } -- GitLab