1 4 package com.tc.test.collections; 5 6 import org.apache.commons.lang.builder.EqualsBuilder; 7 8 import com.tc.util.Stringifier; 9 10 14 class UnequalObjectCountCollectionMismatch extends CollectionMismatch { 15 16 private final int numInCollectionOne; 17 private final int numInCollectionTwo; 18 19 public UnequalObjectCountCollectionMismatch(Object theObject, int objectIndexInCollectionOne, int numInCollectionOne, 20 int numInCollectionTwo, Stringifier describer) { 21 super(theObject, null, true, objectIndexInCollectionOne, -1, describer); 22 23 this.numInCollectionOne = numInCollectionOne; 24 this.numInCollectionTwo = numInCollectionTwo; 25 } 26 27 public String toString() { 28 return "Unequal number of objects: " + originatingString() + " occurs " + this.numInCollectionOne + " times " 29 + "in collection one, but " + this.numInCollectionTwo + " times in collection two."; 30 } 31 32 public boolean equals(Object that) { 33 if (!(that instanceof UnequalObjectCountCollectionMismatch)) return false; 34 35 UnequalObjectCountCollectionMismatch misThat = (UnequalObjectCountCollectionMismatch) that; 36 37 return new EqualsBuilder().appendSuper(super.equals(that)).append(this.numInCollectionOne, 38 misThat.numInCollectionOne) 39 .append(this.numInCollectionTwo, misThat.numInCollectionTwo).isEquals(); 40 } 41 42 } | Popular Tags |