ELEMENTTYPE - The data type stored in the collectionpublic interface ICommonsCollection<ELEMENTTYPE> extends Collection<ELEMENTTYPE>, Serializable
| Modifier and Type | Method and Description |
|---|---|
default EChange |
addAll(ELEMENTTYPE... aElements)
Add an array of elements to this collection.
|
default EChange |
addAll(Enumeration<? extends ELEMENTTYPE> aEnum)
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(Iterator<? extends ELEMENTTYPE> aIter)
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,
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,
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<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 boolean |
containsAny(Predicate<? super ELEMENTTYPE> aFilter)
Check if this collection contains any (=at least one) element matching the
provided filter.
|
default boolean |
containsNone(Predicate<? super ELEMENTTYPE> aFilter)
Check if this collection contains no (=zero) element matching the provided
filter.
|
default boolean |
containsOnly(Predicate<? super ELEMENTTYPE> aFilter)
Check if this collection contains only (=all) elements matching the
provided filter.
|
default void |
findAll(Predicate<? super ELEMENTTYPE> aFilter,
Consumer<? super ELEMENTTYPE> aConsumer)
Find all elements matching the supplied filter and invoke the provided
consumer for each matching element.
|
default <DSTTYPE extends ELEMENTTYPE> |
findAllInstanceOf(Class<DSTTYPE> aDstClass,
Consumer<? super DSTTYPE> aConsumer)
Find all elements that are
instanceOf the provided class and
invoke the provided consumer for all matching elements. |
default <DSTTYPE> void |
findAllMapped(Function<? super ELEMENTTYPE,DSTTYPE> aMapper,
Consumer<? super DSTTYPE> aConsumer)
Convert all elements using the provided function and invoke the provided
consumer for all mapped elements.
|
default <DSTTYPE> void |
findAllMapped(Predicate<? super ELEMENTTYPE> aFilter,
Function<? super ELEMENTTYPE,DSTTYPE> aMapper,
Consumer<? super DSTTYPE> aConsumer)
Find all elements matching the provided filter, convert the matching
elements using the provided function and invoke the provided consumer for
all mapped elements.
|
default ELEMENTTYPE |
findFirst(Predicate<? super ELEMENTTYPE> aFilter)
Find the first element that matches the provided filter.
|
default ELEMENTTYPE |
findFirst(Predicate<? super ELEMENTTYPE> aFilter,
ELEMENTTYPE aDefault)
Find the first element that matches the provided filter.
|
default <DSTTYPE> DSTTYPE |
findFirstMapped(Predicate<? super ELEMENTTYPE> aFilter,
Function<? super ELEMENTTYPE,DSTTYPE> aMapper)
Find the first element that matches the provided filter and convert it
using the provided mapper.
|
default <DSTTYPE> DSTTYPE |
findFirstMapped(Predicate<? super ELEMENTTYPE> aFilter,
Function<? super ELEMENTTYPE,DSTTYPE> aMapper,
DSTTYPE aDefault)
Find the first element that matches the provided filter and convert it
using the provided mapper.
|
default EContinue |
forEachBreakable(IBreakableConsumer<? super ELEMENTTYPE> aConsumer)
A special version of
Iterable.forEach(Consumer) that can break iteration if
a certain requirement is fulfilled. |
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 boolean |
isNotEmpty() |
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 void |
set(ELEMENTTYPE aValue)
Clear all elements and add only the passed value.
|
default void |
setAll(ELEMENTTYPE... aValues)
Clear all elements and add all provided values.
|
default void |
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, toArraydefault boolean isNotEmpty()
true if the map is not empty, false
otherwise.@Nonnull @ReturnsMutableCopy default ICommonsList<ELEMENTTYPE> getCopyAsList()
@Nonnull default EContinue forEachBreakable(IBreakableConsumer<? super ELEMENTTYPE> aConsumer)
Iterable.forEach(Consumer) that can break iteration if
a certain requirement is fulfilled.aConsumer - The consumer to be invoked. May not be null.EContinue.BREAK if iteration was stopped,
EContinue.CONTINUE otherwise.default void findAll(@Nullable Predicate<? super ELEMENTTYPE> aFilter, @Nonnull Consumer<? super ELEMENTTYPE> aConsumer)
aFilter - The filter to be applied. May be null.aConsumer - The consumer to be invoked for all matching elements. May not be
null.default <DSTTYPE> void findAllMapped(@Nonnull Function<? super ELEMENTTYPE,DSTTYPE> aMapper, @Nonnull Consumer<? super DSTTYPE> aConsumer)
DSTTYPE - The destination type to be mapped toaMapper - The mapping function to be executed for all elements. May not be
null.aConsumer - The consumer to be invoked for all mapped elements. May not be
null.default <DSTTYPE> void findAllMapped(@Nullable Predicate<? super ELEMENTTYPE> aFilter, @Nonnull Function<? super ELEMENTTYPE,DSTTYPE> aMapper, @Nonnull Consumer<? super DSTTYPE> aConsumer)
DSTTYPE - The destination type to be mapped toaFilter - The filter to be applied. May be null.aMapper - The mapping function to be executed for all matching elements. May
not be null.aConsumer - The consumer to be invoked for all matching mapped elements. May not
be null.default <DSTTYPE extends ELEMENTTYPE> void findAllInstanceOf(@Nonnull Class<DSTTYPE> aDstClass, @Nonnull Consumer<? super DSTTYPE> aConsumer)
instanceOf the provided class and
invoke the provided consumer for all matching elements. This is a special
implementation of findAllMapped(Predicate, Function, Consumer).DSTTYPE - The destination type to be casted toaDstClass - The class of which all elements should be find. May not be
null.aConsumer - The consumer to be invoked for all instances of the provided class.
May not be null.@Nullable default ELEMENTTYPE findFirst(@Nullable Predicate<? super ELEMENTTYPE> aFilter)
null is returned by default. If this collection does not
maintain order (like Set) it is undefined which value is returned.aFilter - The filter to be applied. May be null.null if no element matches the filter or if the
collection is empty, the first matching element otherwise.findFirst(Predicate, Object)@Nullable default ELEMENTTYPE findFirst(@Nullable Predicate<? super ELEMENTTYPE> aFilter, @Nullable ELEMENTTYPE aDefault)
aFilter - The filter to be applied. May be null.aDefault - The default value to be returned if no element matches. May be
null.findFirst(Predicate)@Nullable default <DSTTYPE> DSTTYPE findFirstMapped(@Nullable Predicate<? super ELEMENTTYPE> aFilter, @Nonnull Function<? super ELEMENTTYPE,DSTTYPE> aMapper)
null is returned by default. If this
collection does not maintain order (like Set) it is undefined which value
is returned.DSTTYPE - The destination type to be mapped toaFilter - The filter to be applied. May be null.aMapper - The mapping function to be executed for the first matching element.
May not be null.null if no element matches the filter or if the
collection is empty, the first matching element otherwise.findFirstMapped(Predicate, Function, Object)@Nullable default <DSTTYPE> DSTTYPE findFirstMapped(@Nullable Predicate<? super ELEMENTTYPE> aFilter, @Nonnull Function<? super ELEMENTTYPE,DSTTYPE> aMapper, @Nullable DSTTYPE aDefault)
DSTTYPE - The destination type to be mapped toaFilter - The filter to be applied. May be null.aMapper - The mapping function to be executed for the first matching element.
May not be null.aDefault - The default value to be returned if no element matches. May be
null.findFirstMapped(Predicate, Function)@Nonnegative default int getCount(@Nullable Predicate<? super ELEMENTTYPE> aFilter)
aFilter - The filter to be applied. May be null.default boolean containsAny(@Nullable Predicate<? super ELEMENTTYPE> aFilter)
aFilter - The filter to be applied. May be null.true if the container is not empty and at least one
element matches the provided filter, false otherwise.
If no filter is provided the response is the same as
isNotEmpty().default boolean containsNone(@Nullable Predicate<? super ELEMENTTYPE> aFilter)
aFilter - The filter to be applied. May be null.true if the container is empty or if no element
matches the provided filter, false otherwise. If no
filter is provided, this is the same as Collection.isEmpty().default boolean containsOnly(@Nonnull Predicate<? super ELEMENTTYPE> aFilter)
isNotEmpty().aFilter - The filter to be applied. May be null.true if this collection is not empty and all elements
matching the filter or if no filter is provided and this collection
is not empty, false otherwise. If no filter is
supplied the return value is identical to isNotEmpty().@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 addIf(@Nullable ELEMENTTYPE aElement, @Nullable Predicate<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 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 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 <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.default void set(@Nullable ELEMENTTYPE aValue)
aValue - The value to be added. May be null.Collection.clear(),
Collection.add(Object)default void setAll(@Nullable Iterable<? extends ELEMENTTYPE> aValues)
aValues - The values to be added. May be null.default void setAll(@Nullable ELEMENTTYPE... aValues)
aValues - The values to be added. May be null.@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–2016 Philip Helger. All rights reserved.