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:35 UTC
(commons-collections) branch master updated (8ef7b7e4f -> a30140839)
This is an automated email from the ASF dual-hosted git repository.
garydgregory pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-collections.git
from 8ef7b7e4f Re-validate entries in PredicatedMap/PredicatedCollection readObject (#682).
new 291ecb5af CompositeCollection#isEmpty(): Use stream API internally.
new 5ebef4f69 CompositeCollection#addComposited(Collection): Use stream API internally.
new 57bf6e414 CompositeCollection#clear(): Use stream API internally.
new 91d325b10 CompositeCollection#contains(Object): Use stream API internally.
new 6d6ea087f CompositeCollection#containsAll(Collection): Use stream API internally.
new ed0f834ae PredicatedCollection: Use stream API internally.
new a30140839 Add Java 26 to GH CI
The 7 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.github/workflows/maven.yml | 4 +--
.../collection/CompositeCollection.java | 40 +++++-----------------
.../collection/PredicatedCollection.java | 18 +++-------
3 files changed, 15 insertions(+), 47 deletions(-)
(commons-collections) 03/07: CompositeCollection#clear(): Use stream API internally.
Posted by gg...@apache.org.
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 57bf6e4144a8bf7c65cbc5453c2e4fd8af0f71f2
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Wed Jun 17 19:41:49 2026 +0000
CompositeCollection#clear(): Use stream API internally.
---
.../apache/commons/collections4/collection/CompositeCollection.java | 6 ++----
1 file changed, 2 insertions(+), 4 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 3581e5ceb..69771dc5b 100644
--- a/src/main/java/org/apache/commons/collections4/collection/CompositeCollection.java
+++ b/src/main/java/org/apache/commons/collections4/collection/CompositeCollection.java
@@ -227,13 +227,11 @@ public class CompositeCollection<E> implements Collection<E>, Serializable {
* This implementation calls {@code clear()} on each collection.
* </p>
*
- * @throws UnsupportedOperationException if clear is unsupported
+ * @throws UnsupportedOperationException if clear is unsupported.
*/
@Override
public void clear() {
- for (final Collection<E> coll : all) {
- coll.clear();
- }
+ all.forEach(Collection::clear);
}
/**
(commons-collections) 02/07: CompositeCollection#addComposited(Collection): Use stream API internally.
Posted by gg...@apache.org.
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 5ebef4f69a4c558e5e16303081a2be0de0a45563
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Wed Jun 17 19:39:11 2026 +0000
CompositeCollection#addComposited(Collection): Use stream API
internally.
---
.../commons/collections4/collection/CompositeCollection.java | 7 ++-----
1 file changed, 2 insertions(+), 5 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 a413bda86..3581e5ceb 100644
--- a/src/main/java/org/apache/commons/collections4/collection/CompositeCollection.java
+++ b/src/main/java/org/apache/commons/collections4/collection/CompositeCollection.java
@@ -24,6 +24,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.Objects;
import java.util.function.Predicate;
+import java.util.stream.Stream;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.iterators.EmptyIterator;
@@ -201,11 +202,7 @@ public class CompositeCollection<E> implements Collection<E>, Serializable {
* @param compositeCollections the Collections to be appended to the composite
*/
public void addComposited(final Collection<E>... compositeCollections) {
- for (final Collection<E> compositeCollection : compositeCollections) {
- if (compositeCollection != null) {
- all.add(compositeCollection);
- }
- }
+ Stream.of(compositeCollections).filter(Objects::nonNull).forEach(all::add);
}
/**
(commons-collections) 04/07: CompositeCollection#contains(Object): Use stream API internally.
Posted by gg...@apache.org.
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 91d325b10ab5e74ded6d5cad94a18930498a23ca
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Wed Jun 17 19:45:08 2026 +0000
CompositeCollection#contains(Object): Use stream API
internally.
---
.../commons/collections4/collection/CompositeCollection.java | 7 +------
1 file changed, 1 insertion(+), 6 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 69771dc5b..094132b8c 100644
--- a/src/main/java/org/apache/commons/collections4/collection/CompositeCollection.java
+++ b/src/main/java/org/apache/commons/collections4/collection/CompositeCollection.java
@@ -245,12 +245,7 @@ public class CompositeCollection<E> implements Collection<E>, Serializable {
*/
@Override
public boolean contains(final Object obj) {
- for (final Collection<E> item : all) {
- if (item.contains(obj)) {
- return true;
- }
- }
- return false;
+ return all.stream().anyMatch(c -> c.contains(obj));
}
/**
(commons-collections) 06/07: PredicatedCollection: Use stream API internally.
Posted by gg...@apache.org.
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 ed0f834ae3484a56b9eec63e1ac53156454c968f
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Wed Jun 17 19:55:38 2026 +0000
PredicatedCollection: Use stream API
internally.
---
.../collections4/collection/PredicatedCollection.java | 18 +++++-------------
1 file changed, 5 insertions(+), 13 deletions(-)
diff --git a/src/main/java/org/apache/commons/collections4/collection/PredicatedCollection.java b/src/main/java/org/apache/commons/collections4/collection/PredicatedCollection.java
index 8727fef66..16d6095e0 100644
--- a/src/main/java/org/apache/commons/collections4/collection/PredicatedCollection.java
+++ b/src/main/java/org/apache/commons/collections4/collection/PredicatedCollection.java
@@ -140,9 +140,7 @@ public class PredicatedCollection<E> extends AbstractCollectionDecorator<E> {
*/
public Builder<E> addAll(final Collection<? extends E> items) {
if (items != null) {
- for (final E item : items) {
- add(item);
- }
+ items.forEach(this::add);
}
return this;
}
@@ -235,8 +233,7 @@ public class PredicatedCollection<E> extends AbstractCollectionDecorator<E> {
*/
public MultiSet<E> createPredicatedMultiSet(final MultiSet<E> multiset) {
Objects.requireNonNull(multiset, "multiset");
- final PredicatedMultiSet<E> predicatedMultiSet =
- PredicatedMultiSet.predicatedMultiSet(multiset, predicate);
+ final PredicatedMultiSet<E> predicatedMultiSet = PredicatedMultiSet.predicatedMultiSet(multiset, predicate);
predicatedMultiSet.addAll(accepted);
return predicatedMultiSet;
}
@@ -376,9 +373,7 @@ public class PredicatedCollection<E> extends AbstractCollectionDecorator<E> {
protected PredicatedCollection(final Collection<E> collection, final Predicate<? super E> predicate) {
super(collection);
this.predicate = Objects.requireNonNull(predicate, "predicate");
- for (final E item : collection) {
- validate(item);
- }
+ collection.forEach(this::validate);
}
/**
@@ -406,9 +401,7 @@ public class PredicatedCollection<E> extends AbstractCollectionDecorator<E> {
*/
@Override
public boolean addAll(final Collection<? extends E> coll) {
- for (final E item : coll) {
- validate(item);
- }
+ coll.forEach(this::validate);
return decorated().addAll(coll);
}
@@ -445,8 +438,7 @@ public class PredicatedCollection<E> extends AbstractCollectionDecorator<E> {
*/
protected void validate(final E object) {
if (!predicate.test(object)) {
- throw new IllegalArgumentException("Cannot add Object '" + object + "' - Predicate '" +
- predicate + "' rejected it");
+ throw new IllegalArgumentException("Cannot add Object '" + object + "' - Predicate '" + predicate + "' rejected it");
}
}
(commons-collections) 07/07: Add Java 26 to GH CI
Posted by gg...@apache.org.
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 a30140839238bead6bd90def76f727ded8d7f013
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Wed Jun 17 20:06:28 2026 +0000
Add Java 26 to GH CI
Replace Java 26-ea with Java 27-ea.
---
.github/workflows/maven.yml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml
index e8ec52707..b691f122d 100644
--- a/.github/workflows/maven.yml
+++ b/.github/workflows/maven.yml
@@ -32,10 +32,10 @@ jobs:
strategy:
max-parallel: 20
matrix:
- java: [ 8, 11, 17, 21, 25 ]
+ java: [ 8, 11, 17, 21, 25, 26 ]
experimental: [false]
include:
- - java: 26-ea
+ - java: 27-ea
experimental: true
steps:
(commons-collections) 01/07: CompositeCollection#isEmpty(): Use stream API internally.
Posted by gg...@apache.org.
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);
}
(commons-collections) 05/07: CompositeCollection#containsAll(Collection): Use stream API internally.
Posted by gg...@apache.org.
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 6d6ea087f18772b8638bb16c47994c7921054052
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Wed Jun 17 19:47:59 2026 +0000
CompositeCollection#containsAll(Collection): Use stream API
internally.
---
.../commons/collections4/collection/CompositeCollection.java | 10 +---------
1 file changed, 1 insertion(+), 9 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 094132b8c..b94f969eb 100644
--- a/src/main/java/org/apache/commons/collections4/collection/CompositeCollection.java
+++ b/src/main/java/org/apache/commons/collections4/collection/CompositeCollection.java
@@ -260,15 +260,7 @@ public class CompositeCollection<E> implements Collection<E>, Serializable {
*/
@Override
public boolean containsAll(final Collection<?> coll) {
- if (coll == null) {
- return false;
- }
- for (final Object item : coll) {
- if (!contains(item)) {
- return false;
- }
- }
- return true;
+ return coll != null && coll.stream().allMatch(this::contains);
}
/**