/** * If a <code>CollectionMutator</code> is defined for this CompositeSet then this * method will be called anyway. * * @param obj object to be removed * @return true if the object is removed, false otherwise */ @Override public boolean remove(final Object obj) { for (final Set<E> set : getSets()) { if (set.contains(obj)) { return set.remove(obj); } } return false; }
/** * 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); }