org.unitils.objectvalidation.rules
Class HashCodeComplientRule

java.lang.Object
  extended by org.unitils.objectvalidation.rules.HashCodeComplientRule
All Implemented Interfaces:
Rule

public class HashCodeComplientRule
extends Object
implements Rule

Assert the compliancy of an object hashCode() method. Rules are the following : - Same objects must produce the same hashCode number. - Equals object have the same number - Unequal numbers produce different hashcode number

Since:
Oct 10, 2013
Author:
Matthieu Mestrez

Constructor Summary
HashCodeComplientRule(ObjectCreator randomFactory, ObjectCloner objectCloner)
           
 
Method Summary
 void checkConsistency(Object object)
          Checks that the hashCode is consistent with the same object.
 void checkTwoEqualsObjectsProduceSameNumber(Object firstObject, Object equalsObject)
          Objects that are equal using the equals method should return the same integer.
 void validate(Class<?> bean)
          Will run the validations on the java class passed in parameter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HashCodeComplientRule

public HashCodeComplientRule(ObjectCreator randomFactory,
                             ObjectCloner objectCloner)
Method Detail

validate

public void validate(Class<?> bean)
Description copied from interface: Rule
Will run the validations on the java class passed in parameter.

Specified by:
validate in interface Rule

checkConsistency

public void checkConsistency(Object object)
Checks that the hashCode is consistent with the same object.


checkTwoEqualsObjectsProduceSameNumber

public void checkTwoEqualsObjectsProduceSameNumber(Object firstObject,
                                                   Object equalsObject)
Objects that are equal using the equals method should return the same integer.



Copyright © 2013-2015. All Rights Reserved.