Package org.aksw.commons.accessors
Class LazyCollection<T,C extends Collection<T>>
java.lang.Object
java.util.AbstractCollection<T>
org.aksw.commons.accessors.LazyCollection<T,C>
- Type Parameters:
T-
- All Implemented Interfaces:
Iterable<T>,Collection<T>
Collection that forwards method calls to another one that is
only instantiated on addition of items if it did not yet exist
Delegates removals to it
- Author:
- raven Apr 9, 2018
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionLazyCollection(SingleValuedAccessor<C> accessor, Supplier<? extends C> ctor, boolean setNullOnEmpty) -
Method Summary
Methods inherited from class java.util.AbstractCollection
addAll, clear, containsAll, isEmpty, removeAll, retainAll, toArray, toArray, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
equals, hashCode, parallelStream, removeIf, spliterator, stream, toArray
-
Field Details
-
accessor
-
ctor
-
setNullOnEmpty
protected boolean setNullOnEmpty -
test
-
-
Constructor Details
-
LazyCollection
public LazyCollection(SingleValuedAccessor<C> accessor, Supplier<? extends C> ctor, boolean setNullOnEmpty)
-
-
Method Details
-
add
- Specified by:
addin interfaceCollection<T>- Overrides:
addin classAbstractCollection<T>
-
checkUnset
-
remove
- Specified by:
removein interfaceCollection<T>- Overrides:
removein classAbstractCollection<T>
-
contains
- Specified by:
containsin interfaceCollection<T>- Overrides:
containsin classAbstractCollection<T>
-
iterator
- Specified by:
iteratorin interfaceCollection<T>- Specified by:
iteratorin interfaceIterable<T>- Specified by:
iteratorin classAbstractCollection<T>
-
size
public int size()- Specified by:
sizein interfaceCollection<T>- Specified by:
sizein classAbstractCollection<T>
-
main
-