/** * Verifies that a set is immutable. * * <p>A set is considered immutable if: * * <ol> * <li>All its mutation methods result in UnsupportedOperationException, and do not change the * underlying contents. * <li>All methods that return objects that can indirectly mutate the set throw * UnsupportedOperationException when those mutators are called. * </ol> * * @param set the presumed-immutable set * @param sampleElement an element of the same type as that contained by {@code set}. {@code set} * may or may not have {@code sampleElement} as a member. */ public static <E> void assertSetIsUnmodifiable(Set<E> set, E sampleElement) { assertCollectionIsUnmodifiable(set, sampleElement); }
Collection<V> values = multimap.asMap().entrySet().iterator().next().getValue(); assertCollectionIsUnmodifiable(values, sampleValue); assertCollectionIsUnmodifiable(multimap.entries(), Maps.immutableEntry(sampleKey, sampleValue)); assertMultimapRemainsUnmodified(multimap, originalEntries); assertCollectionIsUnmodifiable(multimap.get(key), sampleValue); assertMultimapRemainsUnmodified(multimap, originalEntries); assertCollectionIsUnmodifiable(multimap.values(), sampleValue); assertMultimapRemainsUnmodified(multimap, originalEntries);
assertCollectionIsUnmodifiable(multiset, sampleElement);
/** * Verifies that a set is immutable. * * <p>A set is considered immutable if: * * <ol> * <li>All its mutation methods result in UnsupportedOperationException, and do not change the * underlying contents. * <li>All methods that return objects that can indirectly mutate the set throw * UnsupportedOperationException when those mutators are called. * </ol> * * @param set the presumed-immutable set * @param sampleElement an element of the same type as that contained by {@code set}. {@code set} * may or may not have {@code sampleElement} as a member. */ public static <E> void assertSetIsUnmodifiable(Set<E> set, E sampleElement) { assertCollectionIsUnmodifiable(set, sampleElement); }
/** * Verifies that a set is immutable. * * <p>A set is considered immutable if: * <ol> * <li>All its mutation methods result in UnsupportedOperationException, and * do not change the underlying contents. * <li>All methods that return objects that can indirectly mutate the * set throw UnsupportedOperationException when those mutators * are called. * </ol> * * @param set the presumed-immutable set * @param sampleElement an element of the same type as that contained by * {@code set}. {@code set} may or may not have {@code sampleElement} as a * member. */ public static <E> void assertSetIsUnmodifiable( Set<E> set, E sampleElement) { assertCollectionIsUnmodifiable(set, sampleElement); }
Collection<V> values = multimap.asMap().entrySet().iterator().next().getValue(); assertCollectionIsUnmodifiable(values, sampleValue); assertCollectionIsUnmodifiable(multimap.entries(), Maps.immutableEntry(sampleKey, sampleValue)); assertMultimapRemainsUnmodified(multimap, originalEntries); assertCollectionIsUnmodifiable(multimap.get(key), sampleValue); assertMultimapRemainsUnmodified(multimap, originalEntries); assertCollectionIsUnmodifiable(multimap.values(), sampleValue); assertMultimapRemainsUnmodified(multimap, originalEntries);
multimap.asMap().entrySet().iterator().next().getValue(); assertCollectionIsUnmodifiable(values, sampleValue); assertCollectionIsUnmodifiable( multimap.entries(), Maps.immutableEntry(sampleKey, sampleValue)); assertCollectionIsUnmodifiable(multimap.get(key), sampleValue); assertMultimapRemainsUnmodified(multimap, originalEntries); assertCollectionIsUnmodifiable(multimap.values(), sampleValue); assertMultimapRemainsUnmodified(multimap, originalEntries);
assertCollectionIsUnmodifiable(multiset, sampleElement);
assertCollectionIsUnmodifiable(multiset, sampleElement);