java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractSet<E>
com.aoapps.collections.UnionMethodSet<E>
- All Implemented Interfaces:
Iterable<E>
,Collection<E>
,Set<E>
A union set that assumes objects of different classes are not equal. It obtains
the objects by invoking the provided methods. The provided methods will be invoked
on an as-needed basis. It never does any combining.
The following assumptions are made:
- All elements of the returned sets are of the same exact class (within a single method)
- Objects of different classes are not equal.
- No set will contain
null
- Author:
- AO Industries, Inc.
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
static class
static class
A set of values will be obtained from the call to the method.static class
A single value will be obtained from the call to the method. -
Constructor Summary
ConstructorDescriptionUnionMethodSet
(Object target, Class<E> classE, Map<Class<? extends E>, ? extends List<? extends UnionMethodSet.Method<? extends E>>> methodsByClass) -
Method Summary
Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAll
Methods inherited from class java.util.AbstractCollection
add, addAll, clear, containsAll, remove, retainAll, toArray, toArray, toString
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
Methods inherited from interface java.util.Set
add, addAll, clear, containsAll, remove, retainAll, spliterator, toArray, toArray
-
Constructor Details
-
UnionMethodSet
-
-
Method Details
-
size
public int size()This is an expensive operation, since every single method is called, and when there are multiple methods for one class, the sets must be merged to avoid redundant values.- Specified by:
size
in interfaceCollection<E>
- Specified by:
size
in interfaceSet<E>
- Specified by:
size
in classAbstractCollection<E>
-
isEmpty
public boolean isEmpty()Checks if this set is empty. This can be an expensive method since it can potentially call all methods.- Specified by:
isEmpty
in interfaceCollection<E>
- Specified by:
isEmpty
in interfaceSet<E>
- Overrides:
isEmpty
in classAbstractCollection<E>
-
contains
- Specified by:
contains
in interfaceCollection<E>
- Specified by:
contains
in interfaceSet<E>
- Overrides:
contains
in classAbstractCollection<E>
-
iterator
-