org.jtiger.assertion
Class HashCodeMethodContract

java.lang.Object
  extended by org.jtiger.assertion.HashCodeMethodContract

public final class HashCodeMethodContract
extends Object

Makes assertions on the general contract of the java.lang.Object hashCode method. This requires the creation of an instance of ObjectFactory to return instances to use to test. The given ObjectFactory must meet the its own general contract.

Version:
2.1
Build Number 0376
Build Time 2006-07-28 01:50.16.218 CET (GMT + 1)
Author:
Tony Morris
See Also:
ObjectFactory, ObjectFactoryContract, EqualsMethodContract, Object.hashCode()

Method Summary
static void assertHashCodeMethodConsistentResult(ObjectFactory<?> factory, Object... message)
          Asserts that the given ObjectFactory returns instances that meet one aspect of the hashCode method general contract.
static void assertHashCodeMethodEqualOnEqualInstance(ObjectFactory<?> factory, Object... message)
          Asserts that the given ObjectFactory returns instances that meet one aspect of the hashCode method general contract.
static void assertHashCodeMethodFillsContract(ObjectFactory<?> factory, Object... message)
          Asserts that the given ObjectFactory returns instances that meet the entire hashCode method general contract.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

assertHashCodeMethodConsistentResult

public static void assertHashCodeMethodConsistentResult(ObjectFactory<?> factory,
                                                        Object... message)
                                                 throws AssertionException
Asserts that the given ObjectFactory returns instances that meet one aspect of the hashCode method general contract. The hashCode method must consistently return the same value over multiple invocations.

Parameters:
factory - The factory to use to return instances for asserting the aspect of the contract.
message - The assertion message.
Throws:
AssertionException - If the given ObjectFactory returns instances that do not meet the aspect of the hashCode method general contract.

assertHashCodeMethodEqualOnEqualInstance

public static void assertHashCodeMethodEqualOnEqualInstance(ObjectFactory<?> factory,
                                                            Object... message)
                                                     throws AssertionException
Asserts that the given ObjectFactory returns instances that meet one aspect of the hashCode method general contract. The hashCode method must return the same value for instances that are equal according to their equals method implementation.

Parameters:
factory - The factory to use to return instances for asserting the aspect of the contract.
message - The assertion message.
Throws:
AssertionException - If the given ObjectFactory returns instances that do not meet the aspect of the hashCode method general contract.
See Also:
Object.equals(Object)

assertHashCodeMethodFillsContract

public static void assertHashCodeMethodFillsContract(ObjectFactory<?> factory,
                                                     Object... message)
                                              throws AssertionException
Asserts that the given ObjectFactory returns instances that meet the entire hashCode method general contract. The contract is defined by the java.lang.Object hashCode method.

Parameters:
factory - The factory to use to return instances for asserting the entire general contract.
message - The assertion message.
Throws:
AssertionException - If the given ObjectFactory returns instances that do not meet the entire hashCode method general contract.