You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2026/06/17 20:06:36 UTC
(commons-collections) 01/07: CompositeCollection#isEmpty(): Use stream API internally.
This is an automated email from the ASF dual-hosted git repository.
garydgregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-collections.git
commit 291ecb5af0ac5299fd18ba3070636fd426bb82d8
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Wed Jun 17 19:35:09 2026 +0000
CompositeCollection#isEmpty(): Use stream API internally.
---
.../commons/collections4/collection/CompositeCollection.java | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)
diff --git a/src/main/java/org/apache/commons/collections4/collection/CompositeCollection.java b/src/main/java/org/apache/commons/collections4/collection/CompositeCollection.java
index d89db8d66..a413bda86 100644
--- a/src/main/java/org/apache/commons/collections4/collection/CompositeCollection.java
+++ b/src/main/java/org/apache/commons/collections4/collection/CompositeCollection.java
@@ -309,12 +309,7 @@ public class CompositeCollection<E> implements Collection<E>, Serializable {
*/
@Override
public boolean isEmpty() {
- for (final Collection<E> item : all) {
- if (!item.isEmpty()) {
- return false;
- }
- }
- return true;
+ return all.stream().allMatch(Collection::isEmpty);
}
/**
@@ -352,8 +347,7 @@ public class CompositeCollection<E> implements Collection<E>, Serializable {
@Override
public boolean remove(final Object obj) {
if (mutator == null) {
- throw new UnsupportedOperationException(
- "remove() is not supported on CompositeCollection without a CollectionMutator strategy");
+ throw new UnsupportedOperationException("remove() is not supported on CompositeCollection without a CollectionMutator strategy");
}
return mutator.remove(this, all, obj);
}