OneOrMore implements Iterable<T> { @Override public int hashCode() { return new HashCodeBuilder(13, 31) .append(deduplicate) .append(singleItem) .append(collection) .toHashCode(); } OneOrMore();  OneOrMore(final boolean deduplicate);  OneOrMore(final boolean deduplicate, final T item); boolean add(final T item); boolean addAll(final Collection<? extends T> items); void removeAnyItem(); int size(); boolean isEmpty(); boolean contains(final Object o); @Override Iterator<T> iterator(); @Override boolean equals(final Object obj); @Override int hashCode(); @Override String toString();  }
@Test public void shouldBeEqual() { final OneOrMore<Integer> collection1 = new OneOrMore<>(false, 1); final OneOrMore<Integer> collection2 = new OneOrMore<>(false, 1); assertEquals(collection1, collection2); assertEquals(collection1.hashCode(), collection2.hashCode()); }
@Test public void shouldBeEqualWithDeduplicate() { final OneOrMore<Integer> collection1 = new OneOrMore<>(true, 1); final OneOrMore<Integer> collection2 = new OneOrMore<>(true, 1); assertEquals(collection1, collection2); assertEquals(collection1.hashCode(), collection2.hashCode()); }
@Test public void shouldNotBeEqual() { final OneOrMore<Integer> collection1 = new OneOrMore<>(false, 1); final OneOrMore<Integer> collection2 = new OneOrMore<>(false, 2); assertNotEquals(collection1, collection2); assertNotEquals(collection1.hashCode(), collection2.hashCode()); }
@Test public void shouldNotBeEqualWhenDeduplicateDifferent() { final OneOrMore<Integer> collection1 = new OneOrMore<>(false, 1); final OneOrMore<Integer> collection2 = new OneOrMore<>(true, 1); assertNotEquals(collection1, collection2); assertNotEquals(collection1.hashCode(), collection2.hashCode()); }