### Question:
WhileGenerate extends LoopGenerator<E> { @Override public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof WhileGenerate<?>)) { return false; } WhileGenerate<?> other = (WhileGenerate<?>) obj; return other.getWrappedGenerator().equals(getWrappedGenerator()) && other.test.equals(test); } WhileGenerate(Predicate<? super E> test, Generator<? extends E> wrapped); void run(final Procedure<? super E> proc); @Override boolean equals(Object obj); @Override int hashCode();  }### Answer:
@Test public void testEquals() { Generator<Integer> anotherGenerate = new WhileGenerate<Integer>( isLessThanFive, IteratorToGeneratorAdapter.adapt(new IntegerRange(1, 10))); assertEquals(whileGenerate, whileGenerate); assertEquals(whileGenerate, anotherGenerate); assertTrue(!whileGenerate.equals((WhileGenerate<Integer>)null)); Generator<Integer> aGenerateWithADifferentPredicate = new WhileGenerate<Integer>( new Predicate<Integer>() { public boolean test(Integer obj) { return obj < FIVE; } }, IteratorToGeneratorAdapter.adapt(new IntegerRange(1, 10))); assertTrue(!whileGenerate.equals(aGenerateWithADifferentPredicate)); Generator<Integer> aGenerateWithADifferentWrapped = new WhileGenerate<Integer>( isLessThanFive, IteratorToGeneratorAdapter.adapt(new IntegerRange(1,11))); assertTrue(!whileGenerate.equals(aGenerateWithADifferentWrapped)); }