### Question:
EntryIDSet implements Iterable<EntryID> { public void retainAll(EntryIDSet that) { checkNotNull(that, "that must not be null"); if (!concreteImpl.isDefined()) { if ( that.isDefined() ) { concreteImpl = new DefinedImpl(that.getIDs()); } else { concreteImpl = new UndefinedImpl(NO_KEY); } return; } if ( !that.isDefined() ) { return; } final boolean thatSetOverlap = compareForOverlap(getRange(), that.getRange()) == 0; if (thatSetOverlap) { concreteImpl = new DefinedImpl(intersection(concreteImpl.getIDs(), that.getIDs())); } else if (size() != 0) { concreteImpl = new DefinedImpl(); } } private  EntryIDSet(EntryIDSetImplementor concreteImpl); long size(); void toString(StringBuilder buffer); @Override String toString(); long[] toLongArray(); boolean isDefined(); boolean add(EntryID entryID); boolean remove(EntryID entryID); boolean contains(EntryID entryID); void addAll(EntryIDSet that); void retainAll(EntryIDSet that); void removeAll(EntryIDSet that); @Override Iterator<EntryID> iterator(); Iterator<EntryID> iterator(EntryID begin); static final EntryIDSetCodec CODEC_V1; static final EntryIDSetCodec CODEC_V2; }### Answer:
@Test public void testRetainAll() { EntryIDSet retained = newDefinedSet(2, 4, 6, 8); retained.retainAll(newDefinedSet(1, 2, 3, 5, 6, 7, 8)); assertThat(retained.isDefined()).isTrue(); assertIdsEquals(retained, 2, 6, 8); retained = newDefinedSet(2, 4, 6, 8); retained.retainAll(newDefinedSet(1, 3, 5, 7, 9)); assertThat(retained.isDefined()).isTrue(); assertIdsEquals(retained); retained = newUndefinedSet(); retained.retainAll(newDefinedSet(1, 3, 5, 7, 9)); assertThat(retained.isDefined()).isTrue(); assertIdsEquals(retained, 1, 3, 5, 7, 9); }