- 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>
public class UnionMethodSet<E> extends AbstractSet<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:
This class is unmodifiable.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceUnionMethodSet.Method<E>static classUnionMethodSet.ReflectionMethod<E>static classUnionMethodSet.SetMethod<E>A set of values will be obtained from the call to the method.static classUnionMethodSet.SingletonMethod<E>A single value will be obtained from the call to the method.
-
Constructor Summary
Constructors Constructor Description UnionMethodSet(Object target, Class<E> classE, Map<Class<? extends E>,? extends List<? extends UnionMethodSet.Method<? extends E>>> methodsByClass)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancontains(Object element)booleanisEmpty()Checks if this set is empty.Iterator<E>iterator()intsize()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.-
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
-
-
-
-
Method Detail
-
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:
sizein interfaceCollection<E>- Specified by:
sizein interfaceSet<E>- Specified by:
sizein 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:
isEmptyin interfaceCollection<E>- Specified by:
isEmptyin interfaceSet<E>- Overrides:
isEmptyin classAbstractCollection<E>
-
contains
public boolean contains(Object element)
- Specified by:
containsin interfaceCollection<E>- Specified by:
containsin interfaceSet<E>- Overrides:
containsin classAbstractCollection<E>
-
-