/** * Add a Set to this composite. * * @param set the set to add * @throws IllegalArgumentException if a SetMutator is set, but fails to resolve a collision * @throws UnsupportedOperationException if there is no SetMutator set * @throws NullPointerException if {@code set} is null * @see SetMutator */ public synchronized void addComposited(final Set<E> set) { for (final Set<E> existingSet : getSets()) { final Collection<E> intersects = CollectionUtils.intersection(existingSet, set); if (intersects.size() > 0) { if (this.mutator == null) { throw new UnsupportedOperationException( "Collision adding composited set with no SetMutator set"); } getMutator().resolveCollision(this, existingSet, set, intersects); if (CollectionUtils.intersection(existingSet, set).size() > 0) { throw new IllegalArgumentException( "Attempt to add illegal entry unresolved by SetMutator.resolveCollision()"); } } } all.add(set); }