ELEMENTTYPE - The data type stored in the collectionpublic interface ICommonsCollection<ELEMENTTYPE> extends Collection<ELEMENTTYPE>, ICommonsIterable<ELEMENTTYPE>, IHasSize
| Modifier and Type | Method and Description |
|---|---|
default EChange |
addAll(ELEMENTTYPE... aElements)
Add an array of elements to this collection.
|
default EChange |
addAll(ELEMENTTYPE[] aElements,
Predicate<? super ELEMENTTYPE> aFilter)
Add all matching elements of an array this collection.
|
default EChange |
addAll(Enumeration<? extends ELEMENTTYPE> aEnum)
Add all elements of the passed enumeration to this collection.
|
default EChange |
addAll(Enumeration<? extends ELEMENTTYPE> aEnum,
Predicate<? super ELEMENTTYPE> aFilter)
Add all elements of the passed enumeration to this collection.
|
default EChange |
addAll(Iterable<? extends ELEMENTTYPE> aElements)
Add all elements of the passed iterable to this collection.
|
default EChange |
addAll(Iterable<? extends ELEMENTTYPE> aElements,
Predicate<? super ELEMENTTYPE> aFilter)
Add all elements of the passed iterable to this collection.
|
default EChange |
addAll(Iterator<? extends ELEMENTTYPE> aIter)
Add all elements of the passed iterator to this collection.
|
default EChange |
addAll(Iterator<? extends ELEMENTTYPE> aIter,
Predicate<? super ELEMENTTYPE> aFilter)
Add all elements of the passed iterator to this collection.
|
default <SRCTYPE> EChange |
addAllMapped(Iterable<? extends SRCTYPE> aElements,
Function<? super SRCTYPE,? extends ELEMENTTYPE> aMapper)
Add all passed elements after performing a mapping using the provided
function.
|
default <SRCTYPE> EChange |
addAllMapped(Iterable<? extends SRCTYPE> aElements,
Function<? super SRCTYPE,? extends ELEMENTTYPE> aMapper,
Predicate<? super ELEMENTTYPE> aFilter)
Add all passed elements matching the provided filter after performing a
mapping using the provided function.
|
default <SRCTYPE> EChange |
addAllMapped(Iterable<? extends SRCTYPE> aElements,
Predicate<? super SRCTYPE> aFilter,
Function<? super SRCTYPE,? extends ELEMENTTYPE> aMapper)
Add all passed elements matching the provided filter after performing a
mapping using the provided function.
|
default <SRCTYPE> EChange |
addAllMapped(SRCTYPE[] aElements,
Function<? super SRCTYPE,? extends ELEMENTTYPE> aMapper)
Add all passed elements after performing a mapping using the provided
function.
|
default <SRCTYPE> EChange |
addAllMapped(SRCTYPE[] aElements,
Function<? super SRCTYPE,? extends ELEMENTTYPE> aMapper,
Predicate<? super ELEMENTTYPE> aFilter)
Add all passed elements matching the provided filter after performing a
mapping using the provided function.
|
default <SRCTYPE> EChange |
addAllMapped(SRCTYPE[] aElements,
Predicate<? super SRCTYPE> aFilter,
Function<? super SRCTYPE,? extends ELEMENTTYPE> aMapper)
Add all passed elements matching the provided filter after performing a
mapping using the provided function.
|
default EChange |
addIf(ELEMENTTYPE aElement,
Predicate<? super ELEMENTTYPE> aFilter)
Add the passed element to this collection if passed predicate is fulfilled
|
default EChange |
addIfNotNull(ELEMENTTYPE aElement)
Add the passed element to this collection if it is non-
null. |
default EChange |
addObject(ELEMENTTYPE aElement)
add the provided element to the collection using
Collection.add(Object) but
returning a more structured return value. |
default Collection<ELEMENTTYPE> |
getAsUnmodifiable() |
default ELEMENTTYPE |
getAtIndex(int nIndex)
Get the element at the specified index or return
null upon
invalid index. |
default ELEMENTTYPE |
getAtIndex(int nIndex,
ELEMENTTYPE aDefault)
Get the element at the specified index or return the provided default value
upon invalid index.
|
default ELEMENTTYPE |
getAtIndex(Predicate<? super ELEMENTTYPE> aFilter,
int nIndex)
Get the element at the specified index counting only elements matching the
specified filter.
|
default ELEMENTTYPE |
getAtIndex(Predicate<? super ELEMENTTYPE> aFilter,
int nIndex,
ELEMENTTYPE aDefault)
Get the element at the specified index counting only elements matching the
specified filter or return the provided default value upon invalid index.
|
default <DSTTYPE> DSTTYPE |
getAtIndexMapped(int nIndex,
Function<? super ELEMENTTYPE,? extends DSTTYPE> aMapper)
Get the element at the specified index or return
null upon
invalid index. |
default <DSTTYPE> DSTTYPE |
getAtIndexMapped(int nIndex,
Function<? super ELEMENTTYPE,? extends DSTTYPE> aMapper,
DSTTYPE aDefault)
Get the element at the specified index or return the provided default value
upon invalid index.
|
default <DSTTYPE> DSTTYPE |
getAtIndexMapped(Predicate<? super ELEMENTTYPE> aFilter,
int nIndex,
Function<? super ELEMENTTYPE,? extends DSTTYPE> aMapper)
Get the element at the specified index, counting only elements matching the
provided filter and map the resulting element using the provided mapper.
|
default <DSTTYPE> DSTTYPE |
getAtIndexMapped(Predicate<? super ELEMENTTYPE> aFilter,
int nIndex,
Function<? super ELEMENTTYPE,? extends DSTTYPE> aMapper,
DSTTYPE aDefault)
Get the element at the specified index, counting only elements matching the
provided filter and map the resulting element using the provided mapper.
|
default ICommonsList<ELEMENTTYPE> |
getCopyAsList() |
default int |
getCount(Predicate<? super ELEMENTTYPE> aFilter)
Count the number of elements matching the provided filter.
|
default ICommonsList<ELEMENTTYPE> |
getSorted(Comparator<? super ELEMENTTYPE> aComparator)
Return a sorted version of this collection.
|
default IIterableIterator<ELEMENTTYPE> |
iterator2() |
default EChange |
removeAll()
Remove all elements from this collection.
|
default EChange |
removeObject(ELEMENTTYPE aElement)
Remove the provided element from the collection using
Collection.remove(Object) but returning a more structured return value. |
default EChange |
set(ELEMENTTYPE aValue)
Clear all elements and add only the passed value.
|
default EChange |
setAll(ELEMENTTYPE... aValues)
Clear all elements and add all provided values.
|
default EChange |
setAll(Iterable<? extends ELEMENTTYPE> aValues)
Clear all elements and add all provided values.
|
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, parallelStream, remove, removeAll, removeIf, retainAll, size, spliterator, stream, toArray, toArraycontainsAny, containsNone, containsOnly, findAll, findAllInstanceOf, findAllMapped, findAllMapped, findAllMapped, findFirst, findFirst, findFirstMapped, findFirstMapped, forEach, forEachBreakable, forEachByIndex, getCountisEmpty, isNotEmpty, size@Nonnull @ReturnsMutableCopy default ICommonsList<ELEMENTTYPE> getCopyAsList()
@Nonnegative default int getCount(@Nullable Predicate<? super ELEMENTTYPE> aFilter)
getCount in interface ICommonsIterable<ELEMENTTYPE>aFilter - The filter to be applied. May be null.@Nullable default ELEMENTTYPE getAtIndex(@Nonnegative int nIndex)
null upon
invalid index.nIndex - The index to access. Should be ≥ 0.null if the element cannot be accessed.getAtIndex(int, Object)@Nullable default ELEMENTTYPE getAtIndex(@Nonnegative int nIndex, @Nullable ELEMENTTYPE aDefault)
nIndex - The index to access. Should be ≥ 0.aDefault - The value to be returned, if the index is out of bounds. May be
null.getAtIndex(int)@Nullable default ELEMENTTYPE getAtIndex(@Nullable Predicate<? super ELEMENTTYPE> aFilter, @Nonnegative int nIndex)
getAtIndex(int).aFilter - The filter to be applied. May be null.nIndex - The index to be retrieved. Should be ≥ 0.null if no matching element could be accessed.getAtIndex(Predicate, int, Object)@Nullable default ELEMENTTYPE getAtIndex(@Nullable Predicate<? super ELEMENTTYPE> aFilter, @Nonnegative int nIndex, @Nullable ELEMENTTYPE aDefault)
getAtIndex(int, Object).aFilter - The filter to be applied. May be null.nIndex - The index to access. Should be ≥ 0.aDefault - The value to be returned, if the index is out of bounds. May be
null.getAtIndex(Predicate,int)@Nullable default <DSTTYPE> DSTTYPE getAtIndexMapped(@Nonnegative int nIndex, @Nonnull Function<? super ELEMENTTYPE,? extends DSTTYPE> aMapper)
null upon
invalid index.DSTTYPE - The destination type to be mapped tonIndex - The index to access. Should be ≥ 0.aMapper - The mapping function to be executed for the matching element. May
not be null.null if the element cannot be accessed.getAtIndexMapped(int,Function, Object)@Nullable default <DSTTYPE> DSTTYPE getAtIndexMapped(@Nonnegative int nIndex, @Nonnull Function<? super ELEMENTTYPE,? extends DSTTYPE> aMapper, @Nullable DSTTYPE aDefault)
DSTTYPE - The destination type to be mapped tonIndex - The index to access. Should be ≥ 0.aMapper - The mapping function to be executed for the matching element. May
not be null.aDefault - The value to be returned, if the index is out of bounds. May be
null.getAtIndexMapped(int, Function)@Nullable default <DSTTYPE> DSTTYPE getAtIndexMapped(@Nonnull Predicate<? super ELEMENTTYPE> aFilter, @Nonnegative int nIndex, @Nonnull Function<? super ELEMENTTYPE,? extends DSTTYPE> aMapper)
DSTTYPE - The destination type to be mapped toaFilter - The filter to be applied. May be null.nIndex - The index to be accessed. Should be ≥ 0.aMapper - The mapping function to be executed for the matching element. May
not be null.null if no such element at the specified index was
found.getAtIndexMapped(Predicate, int, Function, Object)@Nullable default <DSTTYPE> DSTTYPE getAtIndexMapped(@Nonnull Predicate<? super ELEMENTTYPE> aFilter, @Nonnegative int nIndex, @Nonnull Function<? super ELEMENTTYPE,? extends DSTTYPE> aMapper, @Nullable DSTTYPE aDefault)
DSTTYPE - The destination type to be mapped toaFilter - The filter to be applied. May be null.nIndex - The index to be accessed. Should be ≥ 0.aMapper - The mapping function to be executed for the matching element. May
not be null.aDefault - The default value to be returned if no matching element could be
found.getAtIndexMapped(Predicate, int, Function)@Nonnull default ICommonsList<ELEMENTTYPE> getSorted(@Nonnull Comparator<? super ELEMENTTYPE> aComparator)
CommonsArrayList and sort
this list.aComparator - The comparator used for sorting. May not be null.null list of element. Never null.@Nonnull default EChange addObject(@Nullable ELEMENTTYPE aElement)
Collection.add(Object) but
returning a more structured return value.aElement - The element to be add. May be null.EChange.CHANGED if the element was added successfully,
EChange.UNCHANGED otherwise (e.g. because if is already
contained).Collection.add(Object)@Nonnull default EChange addIf(@Nullable ELEMENTTYPE aElement, @Nullable Predicate<? super ELEMENTTYPE> aFilter)
aElement - The element to be added. May be null.aFilter - The predicate to be executed. May not be null.EChange.CHANGED if the element was added,
EChange.UNCHANGED otherwise.Collection.add(Object)@Nonnull default EChange addIfNotNull(@Nullable ELEMENTTYPE aElement)
null.
This is an optimized version for addIf(Object, Predicate) with the
fixed predicate of != null.aElement - The element to be added if non-null.EChange.CHANGED if the element was added,
EChange.UNCHANGED otherwise.Collection.add(Object),
addIf(Object, Predicate)@Nonnull default EChange addAll(@Nullable ELEMENTTYPE... aElements)
aElements - The elements to be added. May be null.EChange.CHANGED if at least one element was added,
EChange.UNCHANGED. Never null.@Nonnull default EChange addAll(@Nullable Iterable<? extends ELEMENTTYPE> aElements)
aElements - The elements to be added. May be null.EChange.CHANGED if at least one element was added,
EChange.UNCHANGED. Never null.@Nonnull default EChange addAll(@Nullable Enumeration<? extends ELEMENTTYPE> aEnum)
aEnum - The enumeration to be iterated and the elements to be added. May be
null.EChange.CHANGED if at least one element was added,
EChange.UNCHANGED. Never null.@Nonnull default EChange addAll(@Nullable Iterator<? extends ELEMENTTYPE> aIter)
aIter - The iterator to be iterated and the elements to be added. May be
null.EChange.CHANGED if at least one element was added,
EChange.UNCHANGED. Never null.@Nonnull default EChange addAll(@Nullable ELEMENTTYPE[] aElements, @Nullable Predicate<? super ELEMENTTYPE> aFilter)
aElements - The elements to be added. May be null.aFilter - The filter to be applied. May be null.EChange.CHANGED if at least one element was added,
EChange.UNCHANGED. Never null.@Nonnull default EChange addAll(@Nullable Iterable<? extends ELEMENTTYPE> aElements, @Nullable Predicate<? super ELEMENTTYPE> aFilter)
aElements - The elements to be added. May be null.aFilter - The filter to be applied. May be null.EChange.CHANGED if at least one element was added,
EChange.UNCHANGED. Never null.@Nonnull default EChange addAll(@Nullable Enumeration<? extends ELEMENTTYPE> aEnum, @Nullable Predicate<? super ELEMENTTYPE> aFilter)
aEnum - The enumeration to be iterated and the elements to be added. May be
null.aFilter - The filter to be applied. May be null.EChange.CHANGED if at least one element was added,
EChange.UNCHANGED. Never null.@Nonnull default EChange addAll(@Nullable Iterator<? extends ELEMENTTYPE> aIter, @Nullable Predicate<? super ELEMENTTYPE> aFilter)
aIter - The iterator to be iterated and the elements to be added. May be
null.aFilter - The filter to be applied. May be null.EChange.CHANGED if at least one element was added,
EChange.UNCHANGED. Never null.@Nonnull default <SRCTYPE> EChange addAllMapped(@Nullable Iterable<? extends SRCTYPE> aElements, @Nonnull Function<? super SRCTYPE,? extends ELEMENTTYPE> aMapper)
SRCTYPE - The source type to be mapped fromaElements - The elements to be added after mapping. May be null.aMapper - The mapping function to be executed for all provided elements. May
not be null.EChange.CHANGED if at least one element was added,
EChange.UNCHANGED. Never null.@Nonnull default <SRCTYPE> EChange addAllMapped(@Nullable SRCTYPE[] aElements, @Nonnull Function<? super SRCTYPE,? extends ELEMENTTYPE> aMapper)
SRCTYPE - The source type to be mapped fromaElements - The elements to be added after mapping. May be null.aMapper - The mapping function to be executed for all provided elements. May
not be null.EChange.CHANGED if at least one element was added,
EChange.UNCHANGED. Never null.@Nonnull default <SRCTYPE> EChange addAllMapped(@Nullable Iterable<? extends SRCTYPE> aElements, @Nullable Predicate<? super SRCTYPE> aFilter, @Nonnull Function<? super SRCTYPE,? extends ELEMENTTYPE> aMapper)
SRCTYPE - The source type to be mapped fromaElements - The elements to be added after mapping. May be null.aFilter - The filter to be applied. May be null.aMapper - The mapping function to be executed for all provided elements. May
not be null.EChange.CHANGED if at least one element was added,
EChange.UNCHANGED. Never null.@Nonnull default <SRCTYPE> EChange addAllMapped(@Nullable SRCTYPE[] aElements, @Nullable Predicate<? super SRCTYPE> aFilter, @Nonnull Function<? super SRCTYPE,? extends ELEMENTTYPE> aMapper)
SRCTYPE - The source type to be mapped fromaElements - The elements to be added after mapping. May be null.aFilter - The filter to be applied. May be null.aMapper - The mapping function to be executed for all provided elements. May
not be null.EChange.CHANGED if at least one element was added,
EChange.UNCHANGED. Never null.@Nonnull default <SRCTYPE> EChange addAllMapped(@Nullable Iterable<? extends SRCTYPE> aElements, @Nonnull Function<? super SRCTYPE,? extends ELEMENTTYPE> aMapper, @Nullable Predicate<? super ELEMENTTYPE> aFilter)
SRCTYPE - The source type to be mapped fromaElements - The elements to be added after mapping. May be null.aMapper - The mapping function to be executed for all provided elements. May
not be null.aFilter - The filter to be applied on the mapped element. May be
null.EChange.CHANGED if at least one element was added,
EChange.UNCHANGED. Never null.@Nonnull default <SRCTYPE> EChange addAllMapped(@Nullable SRCTYPE[] aElements, @Nonnull Function<? super SRCTYPE,? extends ELEMENTTYPE> aMapper, @Nullable Predicate<? super ELEMENTTYPE> aFilter)
SRCTYPE - The source type to be mapped fromaElements - The elements to be added after mapping. May be null.aMapper - The mapping function to be executed for all provided elements. May
not be null.aFilter - The filter to be applied on the mapped element. May be
null.EChange.CHANGED if at least one element was added,
EChange.UNCHANGED. Never null.@Nonnull default EChange set(@Nullable ELEMENTTYPE aValue)
aValue - The value to be added. May be null.EChange.CHANGED if something was changed,
EChange.UNCHANGED otherwise.Collection.clear(),
Collection.add(Object)@Nonnull default EChange setAll(@Nullable Iterable<? extends ELEMENTTYPE> aValues)
aValues - The values to be added. May be null.EChange.CHANGED if something was changed,
EChange.UNCHANGED otherwise.removeAll(),
addAll(Iterable)@Nonnull default EChange setAll(@Nullable ELEMENTTYPE... aValues)
aValues - The values to be added. May be null.EChange.CHANGED if something was changed,
EChange.UNCHANGED otherwise.removeAll(),
addAll(Object...)@Nonnull default EChange removeAll()
Collection.clear() but it returns a different value whether something was
cleared or not.EChange.CHANGED if the collection was not empty and
something was removed, EChange.UNCHANGED otherwise.Collection.clear()@Nonnull default EChange removeObject(@Nullable ELEMENTTYPE aElement)
Collection.remove(Object) but returning a more structured return value.aElement - The element to be removed. May be null.EChange.CHANGED if the element was removed successfully,
EChange.UNCHANGED otherwise.Collection.remove(Object)@Nonnull @CodingStyleguideUnaware default Collection<ELEMENTTYPE> getAsUnmodifiable()
null
.Collections@Nonnull default IIterableIterator<ELEMENTTYPE> iterator2()
Collection.iterator() but the returned type is more flexible. Never
null.Collection.iterator(),
IterableIteratorCopyright © 2014–2017 Philip Helger. All rights reserved.