Class EqualityAssert


  • public final class EqualityAssert
    extends Object
    Assertions for equality (and hash code generation).
    Since:
    1.0.0
    Version:
    $Id$
    Author:
    tlerios@marketcetera.com
    • Constructor Detail

      • EqualityAssert

        private EqualityAssert()
        Constructor. It is private so that no instances can be created.
    • Method Detail

      • assertEquality

        public static void assertEquality​(String message,
                                          Object o,
                                          Object oEqual,
                                          Object... osUnequal)
        Asserts that the given target object implements equality correctly. If the assertion does not hold, the AssertionError thrown starts with the given message, which may be null if no such custom message prefix is desired.
        Parameters:
        message - The message.
        o - The target object.
        oEqual - Another object that is equal to (but not the same as) the target object.
        osUnequal - Objects that are all unequal to the target object. It may be null or contain null elements.
      • assertEquality

        public static void assertEquality​(Object o,
                                          Object oEqual,
                                          Object... osUnequal)
        Asserts that the given target object implements equality correctly.
        Parameters:
        o - The target object.
        oEqual - Another object that is equal to (but not the same as) the target object.
        osUnequal - Objects that are all unequal to the target object. It may be null or contain null elements.
      • assertEquality

        public static void assertEquality​(String message,
                                          Object o,
                                          int equalIndex,
                                          Object... osOther)
        Asserts that the given target object implements equality correctly. If the assertion does not hold, the AssertionError thrown starts with the given message, which may be null if no such custom message prefix is desired.
        Parameters:
        message - The message.
        o - The target object.
        equalIndex - The index in the collection below for another object that is equal to (but not the same as) the target object; all other collection items are unequal to the target object.
        osOther - A nonempty collection of objects.
      • assertEquality

        public static void assertEquality​(Object o,
                                          int equalIndex,
                                          Object... osOther)
        Asserts that the given target object implements equality correctly.
        Parameters:
        o - The target object.
        equalIndex - The index in the collection below for another object that is equal to (but not the same as) the target object; all other collection items are unequal to the target object.
        osOther - A nonempty collection of objects.