| 27 | import java.util.Set; |
| 28 | |
| 29 | public abstract class AbstractSetEx<E> extends AbstractSet<E> |
| 30 | implements SetEx<E> { |
| 31 | |
| 32 | @Override |
| 33 | public SetEx<E> copy() { |
| 34 | SetEx<E> copy = newSet(); |
| 35 | copy.addAll(this); |
| 36 | return copy; |
| 37 | } |
| 38 | |
| 39 | @Override |
| 40 | public SetEx<E> addAllDiff(Collection<? extends E> c) { |
| 41 | SetEx<E> diff = newSet(); |
| 42 | for (E e : c) { |
| 43 | if (add(e)) { |
| 44 | diff.add(e); |
| 45 | } |
| 46 | } |
| 47 | return diff; |
| 48 | } |
| 49 | |
| 50 | /** |
| 51 | * Creates and returns a new set. The type of the new set should be the |
| 52 | * corresponding subclass. |
| 53 | * This method is provided to ease the implementation of {@link #copy()} |
| 54 | * and {@link #addAllDiff(Collection)}. If a subclass overwrites |
| 55 | * above two methods, it does not need to re-implement this method. |
| 56 | */ |
| 57 | protected SetEx<E> newSet() { |
| 58 | throw new UnsupportedOperationException(); |
| 59 | } |
| 60 | |
| 61 | @Override |
| 62 | public boolean hasOverlapWith(Set<E> other) { |
| 63 | return Sets.haveOverlap(this, other); |
| 64 | } |
| 65 | } |
nothing calls this directly
no outgoing calls
no test coverage detected