The methods containsAny
and containsNone
were added to the RichIterable
interface in the Eclipse Collections 11.1 release. There are also methods named containsAnyIterable
and containsNoneIterable
which take Iterable
as a parameter instead of Collection
.
The following now works using your code example.
MutableSet<String> set1 = Sets.mutable.of("a", "b", "c");
ImmutableSet<String> set2 = Sets.immutable.of("c", "d", "e");
MutableSet<String> set3 = Sets.mutable.of("c", "d", "e");
MutableSet<String> set4 = Sets.mutable.of("d", "e", "f");
ImmutableSet<String> set5 = Sets.immutable.of("d", "e", "f");
Assertions.assertTrue(set1.containsAnyIterable(set2));
Assertions.assertTrue(set1.containsAny(set3));
Assertions.assertFalse(set1.containsAny(set4));
Assertions.assertFalse(set1.containsAnyIterable(set5));
Assertions.assertTrue(set1.containsNone(set4));
Assertions.assertTrue(set1.containsNoneIterable(set5));
I used containsAnyIterable
and containsNoneIterable
for the ImmutableSet
examples because containsAny
and containsNone
take java.util.Collection
as a parameter type and ImmutableSet
does not extend this interface. The containsAnyIterable
and containsNoneIteable
methods work with ImmutableSet
because it does extend java.lang.Iterable
.