diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml
index c928d7b1b4..e072e3dd79 100644
--- a/.github/workflows/codeql-analysis.yml
+++ b/.github/workflows/codeql-analysis.yml
@@ -37,6 +37,7 @@ jobs:
security-events: write
strategy:
+ max-parallel: 20
fail-fast: false
matrix:
language: [ 'java' ]
@@ -45,10 +46,10 @@ jobs:
steps:
- name: Checkout repository
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
+ uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- - uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
+ - uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 #v5.0.3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
@@ -57,7 +58,7 @@ jobs:
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
- uses: github/codeql-action/init@cf1bb45a277cb3c205638b2cd5c984db1c46a412 # v4.31.7
+ uses: github/codeql-action/init@c6f931105cb2c34c8f901cc885ba1e2e259cf745 # v4.34.0
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -68,7 +69,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
- uses: github/codeql-action/autobuild@cf1bb45a277cb3c205638b2cd5c984db1c46a412 # v4.31.7
+ uses: github/codeql-action/autobuild@c6f931105cb2c34c8f901cc885ba1e2e259cf745 # v4.34.0
# âšī¸ Command-line programs to run using the OS shell.
# đ https://git.io/JvXDl
@@ -82,4 +83,4 @@ jobs:
# make release
- name: Perform CodeQL Analysis
- uses: github/codeql-action/analyze@cf1bb45a277cb3c205638b2cd5c984db1c46a412 # v4.31.7
+ uses: github/codeql-action/analyze@c6f931105cb2c34c8f901cc885ba1e2e259cf745 # v4.34.0
diff --git a/.github/workflows/dependency-review.yml b/.github/workflows/dependency-review.yml
index 1df8666044..a04da50909 100644
--- a/.github/workflows/dependency-review.yml
+++ b/.github/workflows/dependency-review.yml
@@ -26,6 +26,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: 'Checkout Repository'
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
+ uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: 'Dependency Review PR'
uses: actions/dependency-review-action@3c4e3dcb1aa7874d2c16be7d79418e9b7efd6261 # v4.8.2
diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml
index a9af1283e7..70680be10f 100644
--- a/.github/workflows/maven.yml
+++ b/.github/workflows/maven.yml
@@ -26,6 +26,7 @@ jobs:
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.experimental }}
strategy:
+ max-parallel: 20
matrix:
java: [ 8, 11, 17, 21, 25 ]
experimental: [false]
@@ -34,17 +35,17 @@ jobs:
experimental: true
steps:
- - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- - uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
+ - uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 #v5.0.3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Set up JDK ${{ matrix.java }}
- uses: actions/setup-java@f2beeb24e141e01a676f977032f5a29d81c9e27e # v5.1.0
+ uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
with:
distribution: 'temurin'
java-version: ${{ matrix.java }}
diff --git a/.github/workflows/scorecards-analysis.yml b/.github/workflows/scorecards-analysis.yml
index 7405a82abd..7182c34001 100644
--- a/.github/workflows/scorecards-analysis.yml
+++ b/.github/workflows/scorecards-analysis.yml
@@ -40,7 +40,7 @@ jobs:
steps:
- name: "Checkout code"
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
+ uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
@@ -57,13 +57,13 @@ jobs:
publish_results: true
- name: "Upload artifact"
- uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
+ uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: SARIF file
path: results.sarif
retention-days: 5
- name: "Upload to code-scanning"
- uses: github/codeql-action/upload-sarif@cf1bb45a277cb3c205638b2cd5c984db1c46a412 # v4.31.7
+ uses: github/codeql-action/upload-sarif@c6f931105cb2c34c8f901cc885ba1e2e259cf745 # v4.34.0
with:
sarif_file: results.sarif
diff --git a/NOTICE.txt b/NOTICE.txt
index 518b76e2c9..8c3e93e4e8 100644
--- a/NOTICE.txt
+++ b/NOTICE.txt
@@ -1,5 +1,5 @@
Apache Commons Collections
-Copyright 2001-2025 The Apache Software Foundation
+Copyright 2001-2026 The Apache Software Foundation
This product includes software developed at
The Apache Software Foundation (https://www.apache.org/).
diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt
index d615e65a9a..473141ccfe 100644
--- a/RELEASE-NOTES.txt
+++ b/RELEASE-NOTES.txt
@@ -266,7 +266,7 @@ Fixed Bugs
* COLLECTIONS-836: Correct test of BidiMap to optionally ignore testing the key set matches the values order.
Ordering is not specified for some BidiMaps such as DualHashBidiMaps. Thanks to Anant Dahiya.
* COLLECTIONS-737: Return 0 immediately if the given iterable is null in IterableUtils#size. Update tests. Thanks to Prodigysov.
-* COLLECTIONS-697: JavaDoc for FixedSizeList should warn that modifying underlying list is still allowed and is not prevented Thanks to Ranjan George.
+* COLLECTIONS-697: Javadoc for FixedSizeList should warn that modifying underlying list is still allowed and is not prevented Thanks to Ranjan George.
* Fill in some map test cases #104. Thanks to dota17.
* COLLECTIONS-738: Remove the redundant assertNull in IterableUtilsTest.find and update Javadocs. Thanks to Pengyu Nie.
* COLLECTIONS-724: Simplify two remove-if loops #77. Thanks to Eitan Adler.
diff --git a/pom.xml b/pom.xml
index c51e26167d..df28581c9a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -19,7 +19,7 @@
org.apache.commons
commons-parent
- 93
+ 97
4.0.0
commons-collections4
@@ -74,7 +74,7 @@
commons-codec
commons-codec
- 1.20.0
+ 1.21.0
true
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 01f289224e..70967d8b4f 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -41,17 +41,19 @@
Fix SortedProperties.stringPropertyNames() returned an unsorted Set.
Fix SortedProperties.forEach() called its consumer out of order.
Fix Apache RAT plugin console warnings.
+ Add MultiValuedMap.inverted() #665.
Add generics to UnmodifiableIterator for the wrapped type.
Add a Maven benchmark profile for JMH.
+ Add a Maven benchmark profile for JMH.
- Bump org.apache.commons:commons-parent from 81 to 93 #612, #645, #662, #663.
+ Bump org.apache.commons:commons-parent from 81 to 97 #612, #645, #662, #663.
Bump com.google.guava:guava-testlib from 33.3.1-jre to 33.5.0-jre #644.
Bump PMD from 7.8.0 to 7.13.0 (now inherited from parent POM).
Bump org.easymock:easymock from 5.5.0 to 5.6.0 #617.
[test] Bump org.apache.commons:commons-lang3 from 3.17.0 to 3.20.0 #625.
[test] Bump commons-io:commons-io from 2.19.0 to 2.21.0.
- Bump commons-codec:commons-codec from 1.18.0 to 1.20.0.
+ Bump commons-codec:commons-codec from 1.18.0 to 1.21.0.
@@ -270,7 +272,7 @@
Return 0 immediately if the given iterable is null in IterableUtils#size. Update tests.
- JavaDoc for FixedSizeList should warn that modifying underlying list is still allowed and is not prevented
+ Javadoc for FixedSizeList should warn that modifying underlying list is still allowed and is not prevented
Fill in some map test cases #104.
diff --git a/src/main/java/org/apache/commons/collections4/ClosureUtils.java b/src/main/java/org/apache/commons/collections4/ClosureUtils.java
index d65472f177..4ad525c4dd 100644
--- a/src/main/java/org/apache/commons/collections4/ClosureUtils.java
+++ b/src/main/java/org/apache/commons/collections4/ClosureUtils.java
@@ -35,25 +35,25 @@
* {@code ClosureUtils} provides reference implementations and utilities
* for the Closure functor interface. The supplied closures are:
*
- * - Invoker - invokes a method on the input object
- *
- For - repeatedly calls a closure for a fixed number of times
- *
- While - repeatedly calls a closure while a predicate is true
- *
- Chained - chains two or more closures together
- *
- If - calls one closure or another based on a predicate
- *
- Switch - calls one closure based on one or more predicates
- *
- SwitchMap - calls one closure looked up from a Map
- *
- Transformer - wraps a Transformer as a Closure
- *
- NOP - does nothing
- *
- Exception - always throws an exception
+ *
- Invoker - invokes a method on the input object
+ * - For - repeatedly calls a closure for a fixed number of times
+ * - While - repeatedly calls a closure while a predicate is true
+ * - Chained - chains two or more closures together
+ * - If - calls one closure or another based on a predicate
+ * - Switch - calls one closure based on one or more predicates
+ * - SwitchMap - calls one closure looked up from a Map
+ * - Transformer - wraps a Transformer as a Closure
+ * - NOP - does nothing
+ * - Exception - always throws an exception
*
*
* Since v4.1 only closures which are considered to be safe are
* Serializable. Closures considered to be unsafe for serialization are:
*
*
- * - Invoker
- *
- For
- *
- While
+ *
- Invoker
+ * - For
+ * - While
*
*
* @since 3.0
diff --git a/src/main/java/org/apache/commons/collections4/CollectionUtils.java b/src/main/java/org/apache/commons/collections4/CollectionUtils.java
index b782bbf267..9cc1b80e60 100644
--- a/src/main/java/org/apache/commons/collections4/CollectionUtils.java
+++ b/src/main/java/org/apache/commons/collections4/CollectionUtils.java
@@ -58,6 +58,7 @@ public class CollectionUtils {
/**
* Helper class to easily access cardinality properties of two collections.
+ *
* @param the element type
*/
private static class CardinalityHelper {
@@ -169,6 +170,7 @@ public int hashCode() {
/**
* Helper class for set-related operations, for example union, subtract, intersection.
+ *
* @param the element type
*/
private static final class SetOperationCardinalityHelper extends CardinalityHelper implements Iterable {
@@ -181,6 +183,7 @@ private static final class SetOperationCardinalityHelper extends CardinalityH
/**
* Create a new set operation helper from the two collections.
+ *
* @param a the first collection
* @param b the second collection
*/
@@ -200,6 +203,7 @@ public Iterator iterator() {
/**
* Returns the resulting collection.
+ *
* @return the result
*/
public Collection list() {
@@ -208,6 +212,7 @@ public Collection list() {
/**
* Add the object {@code count} times to the result collection.
+ *
* @param obj the object to add
* @param count the count
*/
@@ -373,6 +378,7 @@ public static int cardinality(final O obj, final Iterable super O> collect
/**
* Ensures an index is not negative.
+ *
* @param index the index to check.
* @throws IndexOutOfBoundsException if the index is negative.
*/
@@ -736,9 +742,9 @@ public static int countMatches(final Iterable input, final Predicate su
*
*
* This is equivalent to
- * {@code {@link #subtract subtract}({@link #union union(a,b)},{@link #intersection intersection(a,b)})}
+ * {@code {@link #subtract subtract}({@link #union union(a, b)},{@link #intersection intersection(a, b)})}
* or
- * {@code {@link #union union}({@link #subtract subtract(a,b)},{@link #subtract subtract(b,a)})}.
+ * {@code {@link #union union}({@link #subtract subtract(a, b)},{@link #subtract subtract(b, a)})}.
*
*
* @param a the first collection, must not be null
@@ -1838,11 +1844,11 @@ public static super O>> R selectRejected(final Iterab
* This method can handles objects as follows
*
*
- * - Collection - the collection size
- *
- Map - the map size
- *
- Array - the array size
- *
- Iterator - the number of elements remaining in the iterator
- *
- Enumeration - the number of elements remaining in the enumeration
+ *
- Collection - the collection size
+ * - Map - the map size
+ * - Array - the array size
+ * - Iterator - the number of elements remaining in the iterator
+ * - Enumeration - the number of elements remaining in the enumeration
*
*
* @param object the object to get the size of, may be null
@@ -1887,11 +1893,11 @@ public static int size(final Object object) {
* This method can handles objects as follows
*
*
- * - Collection - via collection isEmpty
- *
- Map - via map isEmpty
- *
- Array - using array size
- *
- Iterator - via hasNext
- *
- Enumeration - via hasMoreElements
+ *
- Collection - via collection isEmpty
+ * - Map - via map isEmpty
+ * - Array - using array size
+ * - Iterator - via hasNext
+ * - Enumeration - via hasMoreElements
*
*
* Note: This method is named to avoid clashing with
diff --git a/src/main/java/org/apache/commons/collections4/Equator.java b/src/main/java/org/apache/commons/collections4/Equator.java
index c43ab1d748..9d99322ffc 100644
--- a/src/main/java/org/apache/commons/collections4/Equator.java
+++ b/src/main/java/org/apache/commons/collections4/Equator.java
@@ -27,6 +27,7 @@
* @since 4.0
*/
public interface Equator {
+
/**
* Evaluates the two arguments for their equality.
*
diff --git a/src/main/java/org/apache/commons/collections4/FactoryUtils.java b/src/main/java/org/apache/commons/collections4/FactoryUtils.java
index 74628112ee..b80c7faf56 100644
--- a/src/main/java/org/apache/commons/collections4/FactoryUtils.java
+++ b/src/main/java/org/apache/commons/collections4/FactoryUtils.java
@@ -25,19 +25,19 @@
* {@code FactoryUtils} provides reference implementations and utilities
* for the Factory functor interface. The supplied factories are:
*
- * - Prototype - clones a specified object
- *
- Instantiate - creates objects using reflection
- *
- Constant - always returns the same object
- *
- Null - always returns null
- *
- Exception - always throws an exception
+ *
- Prototype - clones a specified object
+ * - Instantiate - creates objects using reflection
+ * - Constant - always returns the same object
+ * - Null - always returns null
+ * - Exception - always throws an exception
*
*
* Since v4.1 only factories which are considered to be safe are
* Serializable. Factories considered to be unsafe for serialization are:
*
*
- * - Prototype
- *
- Instantiate
+ *
- Prototype
+ * - Instantiate
*
*
* @since 3.0
diff --git a/src/main/java/org/apache/commons/collections4/FluentIterable.java b/src/main/java/org/apache/commons/collections4/FluentIterable.java
index 0c2b887438..77523d3596 100644
--- a/src/main/java/org/apache/commons/collections4/FluentIterable.java
+++ b/src/main/java/org/apache/commons/collections4/FluentIterable.java
@@ -35,12 +35,11 @@
*
*
* - fluent methods which return a new {@code FluentIterable} instance,
- * providing a view of the original iterable (for example filter(Predicate));
+ * providing a view of the original iterable (for example filter(Predicate));
* - conversion methods which copy the FluentIterable's contents into a
- * new collection or array (for example toList());
+ * new collection or array (for example toList());
* - utility methods which answer questions about the FluentIterable's
- * contents (for example size(), anyMatch(Predicate)).
- *
-
+ * contents (for example size(), anyMatch(Predicate)).
*
*
* The following example outputs the first 3 even numbers in the range [1, 10]
@@ -139,6 +138,7 @@ public static FluentIterable of(final T... elements) {
/**
* Create a new FluentIterable by wrapping the provided iterable.
+ *
* @param iterable the iterable to wrap
*/
private FluentIterable(final Iterable iterable) {
@@ -218,8 +218,8 @@ public Enumeration asEnumeration() {
* Example: natural ordering
*
*
- * - this contains elements [1, 3, 5, 7]
- *
- other contains elements [2, 4, 6, 8]
+ *
- this contains elements [1, 3, 5, 7]
+ * - other contains elements [2, 4, 6, 8]
*
*
* The returned iterable will traverse the elements in the following
@@ -243,8 +243,8 @@ public FluentIterable collate(final Iterable extends E> other) {
* Example: descending order
*
*
- * - this contains elements [7, 5, 3, 1]
- *
- other contains elements [8, 6, 4, 2]
+ *
- this contains elements [7, 5, 3, 1]
+ * - other contains elements [8, 6, 4, 2]
*
*
* The returned iterable will traverse the elements in the following
diff --git a/src/main/java/org/apache/commons/collections4/IterableGet.java b/src/main/java/org/apache/commons/collections4/IterableGet.java
index 85aca7634b..0c3b893729 100644
--- a/src/main/java/org/apache/commons/collections4/IterableGet.java
+++ b/src/main/java/org/apache/commons/collections4/IterableGet.java
@@ -25,6 +25,7 @@
* @see Put
*/
public interface IterableGet extends Get {
+
/**
* Obtains a {@code MapIterator} over the map.
*
diff --git a/src/main/java/org/apache/commons/collections4/IterableUtils.java b/src/main/java/org/apache/commons/collections4/IterableUtils.java
index 0a2e1d224c..5a06d3fb08 100644
--- a/src/main/java/org/apache/commons/collections4/IterableUtils.java
+++ b/src/main/java/org/apache/commons/collections4/IterableUtils.java
@@ -39,10 +39,10 @@
*
*
* - All decorator methods are not null-safe for the provided Iterable argument; for example, they will throw a {@link NullPointerException} if a
- * null Iterable is passed as argument.
+ * null Iterable is passed as argument.
* - All other utility methods are null-safe for the provided Iterable argument; for example, they will treat a null Iterable the same way as an empty one.
* For other arguments which are null, a {@link Predicate} will result in a {@link NullPointerException}. Exception: passing a null {@link Comparator} is
- * equivalent to a Comparator with natural ordering.
+ * equivalent to a Comparator with natural ordering.
*
*
* @since 4.1
@@ -624,7 +624,7 @@ public Iterator iterator() {
return new LazyIteratorChain() {
@Override
protected Iterator extends E> nextIterator(final int count) {
- if (IterableUtils.isEmpty(iterable)) {
+ if (IterableUtils.isEmpty(iterable)) { //NOPMD: qualifier is needed here
return null;
}
return iterable.iterator();
diff --git a/src/main/java/org/apache/commons/collections4/IteratorUtils.java b/src/main/java/org/apache/commons/collections4/IteratorUtils.java
index ac11f21abc..6a7e53d0de 100644
--- a/src/main/java/org/apache/commons/collections4/IteratorUtils.java
+++ b/src/main/java/org/apache/commons/collections4/IteratorUtils.java
@@ -112,6 +112,7 @@ public class IteratorUtils {
*/
@SuppressWarnings("rawtypes")
public static final OrderedMapIterator EMPTY_ORDERED_MAP_ITERATOR = EmptyOrderedMapIterator.INSTANCE;
+
/**
* Default delimiter used to delimit elements while converting an Iterator
* to its String representation.
@@ -392,7 +393,6 @@ public static Iterable asMultipleUseIterable(final Iterator extends E>
return new IteratorIterable<>(iterator, true);
}
- // Bounded
/**
* Decorates the specified iterator to return at most the given number
* of elements.
@@ -759,6 +759,7 @@ private static E find(final Iterator iterator, final Predicate super E>
* The Iterator is advanced to {@code 0} (or to the end, if
* {@code 0} exceeds the number of entries) as a side effect of this method.
*
+ *
* @param the type of object in the {@link Iterator}
* @param iterator the iterator to get a value from
* @return the first object
@@ -866,17 +867,17 @@ static E get(final Iterator iterator, final int index, final IntFunction<
* This method can handle objects as follows
*
*
- * - null - empty iterator
- *
- Iterator - returned directly
- *
- Enumeration - wrapped
- *
- Collection - iterator from collection returned
- *
- Map - values iterator returned
- *
- Dictionary - values (elements) enumeration returned as iterator
- *
- array - iterator over array returned
- *
- object with iterator() public method accessed by reflection
- *
- object - singleton iterator
- *
- NodeList - iterator over the list
- *
- Node - iterator over the child nodes
+ *
- null - empty iterator
+ * - Iterator - returned directly
+ * - Enumeration - wrapped
+ * - Collection - iterator from collection returned
+ * - Map - values iterator returned
+ * - Dictionary - values (elements) enumeration returned as iterator
+ * - array - iterator over array returned
+ * - object with iterator() public method accessed by reflection
+ * - object - singleton iterator
+ * - NodeList - iterator over the list
+ * - Node - iterator over the child nodes
*
*
* @param obj the object to convert to an iterator
diff --git a/src/main/java/org/apache/commons/collections4/ListUtils.java b/src/main/java/org/apache/commons/collections4/ListUtils.java
index 1fb90acc69..7d658cb434 100644
--- a/src/main/java/org/apache/commons/collections4/ListUtils.java
+++ b/src/main/java/org/apache/commons/collections4/ListUtils.java
@@ -96,6 +96,7 @@ public void visitKeepCommand(final E object) {
/**
* Provides a partition view on a {@link List}.
+ *
* @since 4.0
*/
private static final class Partition extends AbstractList> {
diff --git a/src/main/java/org/apache/commons/collections4/MapUtils.java b/src/main/java/org/apache/commons/collections4/MapUtils.java
index 2f52dd9ba1..800199dfe2 100644
--- a/src/main/java/org/apache/commons/collections4/MapUtils.java
+++ b/src/main/java/org/apache/commons/collections4/MapUtils.java
@@ -60,19 +60,19 @@
*
*
*
- * - {@link #fixedSizeMap(Map)}
- *
- {@link #fixedSizeSortedMap(SortedMap)}
- *
- {@link #lazyMap(Map,Factory)}
- *
- {@link #lazyMap(Map,Transformer)}
- *
- {@link #lazySortedMap(SortedMap,Factory)}
- *
- {@link #lazySortedMap(SortedMap,Transformer)}
- *
- {@link #predicatedMap(Map,Predicate,Predicate)}
- *
- {@link #predicatedSortedMap(SortedMap,Predicate,Predicate)}
- *
- {@link #transformedMap(Map, Transformer, Transformer)}
- *
- {@link #transformedSortedMap(SortedMap, Transformer, Transformer)}
- *
- {@link #multiValueMap(Map)}
- *
- {@link #multiValueMap(Map, Class)}
- *
- {@link #multiValueMap(Map, Factory)}
+ *
- {@link #fixedSizeMap(Map)}
+ * - {@link #fixedSizeSortedMap(SortedMap)}
+ * - {@link #lazyMap(Map,Factory)}
+ * - {@link #lazyMap(Map,Transformer)}
+ * - {@link #lazySortedMap(SortedMap,Factory)}
+ * - {@link #lazySortedMap(SortedMap,Transformer)}
+ * - {@link #predicatedMap(Map,Predicate,Predicate)}
+ * - {@link #predicatedSortedMap(SortedMap,Predicate,Predicate)}
+ * - {@link #transformedMap(Map, Transformer, Transformer)}
+ * - {@link #transformedSortedMap(SortedMap, Transformer, Transformer)}
+ * - {@link #multiValueMap(Map)}
+ * - {@link #multiValueMap(Map, Class)}
+ * - {@link #multiValueMap(Map, Factory)}
*
*
* @since 1.0
diff --git a/src/main/java/org/apache/commons/collections4/MultiMapUtils.java b/src/main/java/org/apache/commons/collections4/MultiMapUtils.java
index ef7fc8c96c..226f1dc522 100644
--- a/src/main/java/org/apache/commons/collections4/MultiMapUtils.java
+++ b/src/main/java/org/apache/commons/collections4/MultiMapUtils.java
@@ -20,6 +20,7 @@
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import org.apache.commons.collections4.bag.HashBag;
@@ -157,6 +158,29 @@ public static Set getValuesAsSet(final MultiValuedMap map, final
return null;
}
+ /**
+ * Inverts the mappings from an input MultiValuedMap by adding entries to an output MultiValuedMap. The input is unchanged.
+ *
+ * Use this method to have complete control of the output MultiValuedMap or when merging several inverse mappings. In simple cases, consider using
+ * {@link MultiValuedMap#inverted()} method.
+ *
+ *
+ * @param the input value type and output key type.
+ * @param the input key type and output value type.
+ * @param the output MultiValuedMap type where {@code K} is the key type and {@code V} is the value type.
+ * @param input The input key-value mappings of type {@code }.
+ * @param output The output value-key mappings of type {@code }.
+ * @return The updated output MultiValuedMap of type {@code }
+ * @see MultiValuedMap#inverted()
+ * @since 4.6.0
+ */
+ public static > M invert(final MultiValuedMap extends V, ? extends K> input, final M output) {
+ for (final Map.Entry extends V, ? extends K> e : input.entries()) {
+ output.put(e.getValue(), e.getKey());
+ }
+ return output;
+ }
+
/**
* Null-safe check if the specified {@code MultiValuedMap} is empty.
*
diff --git a/src/main/java/org/apache/commons/collections4/MultiValuedMap.java b/src/main/java/org/apache/commons/collections4/MultiValuedMap.java
index 96d2f6b086..31ae1f005d 100644
--- a/src/main/java/org/apache/commons/collections4/MultiValuedMap.java
+++ b/src/main/java/org/apache/commons/collections4/MultiValuedMap.java
@@ -140,6 +140,18 @@ public interface MultiValuedMap {
*/
Collection get(K key);
+ /**
+ * Returns a new MultiValuedMap with inverted mappings.
+ * The new multimap will have a value-to-key mapping
+ * for each key-to-value mapping in the original.
+ *
+ * @return a new MultiValuedMap with inverted mappings
+ * @since 4.6.0
+ */
+ default MultiValuedMap inverted() {
+ throw new UnsupportedOperationException(getClass() + ".inverted()");
+ }
+
/**
* Returns {@code true} if this map contains no key-value mappings.
*
diff --git a/src/main/java/org/apache/commons/collections4/PredicateUtils.java b/src/main/java/org/apache/commons/collections4/PredicateUtils.java
index bce080858b..0229f05037 100644
--- a/src/main/java/org/apache/commons/collections4/PredicateUtils.java
+++ b/src/main/java/org/apache/commons/collections4/PredicateUtils.java
@@ -45,24 +45,24 @@
* {@code PredicateUtils} provides reference implementations and utilities
* for the Predicate functor interface. The supplied predicates are:
*
- * - Invoker - returns the result of a method call on the input object
- *
- InstanceOf - true if the object is an instanceof a class
- *
- Equal - true if the object equals() a specified object
- *
- Identity - true if the object == a specified object
- *
- Null - true if the object is null
- *
- NotNull - true if the object is not null
- *
- Unique - true if the object has not already been evaluated
- *
- And/All - true if all of the predicates are true
- *
- Or/Any - true if any of the predicates is true
- *
- Either/One - true if only one of the predicate is true
- *
- Neither/None - true if none of the predicates are true
- *
- Not - true if the predicate is false, and vice versa
- *
- Transformer - wraps a Transformer as a Predicate
- *
- True - always return true
- *
- False - always return false
- *
- Exception - always throws an exception
- *
- NullIsException/NullIsFalse/NullIsTrue - check for null input
- *
- Transformed - transforms the input before calling the predicate
+ *
- Invoker - returns the result of a method call on the input object
+ * - InstanceOf - true if the object is an instanceof a class
+ * - Equal - true if the object equals() a specified object
+ * - Identity - true if the object == a specified object
+ * - Null - true if the object is null
+ * - NotNull - true if the object is not null
+ * - Unique - true if the object has not already been evaluated
+ * - And/All - true if all of the predicates are true
+ * - Or/Any - true if any of the predicates is true
+ * - Either/One - true if only one of the predicate is true
+ * - Neither/None - true if none of the predicates are true
+ * - Not - true if the predicate is false, and vice versa
+ * - Transformer - wraps a Transformer as a Predicate
+ * - True - always return true
+ * - False - always return false
+ * - Exception - always throws an exception
+ * - NullIsException/NullIsFalse/NullIsTrue - check for null input
+ * - Transformed - transforms the input before calling the predicate
*
*
* All the supplied predicates are Serializable.
diff --git a/src/main/java/org/apache/commons/collections4/SetUtils.java b/src/main/java/org/apache/commons/collections4/SetUtils.java
index bc375cfe4a..9b77528dfa 100644
--- a/src/main/java/org/apache/commons/collections4/SetUtils.java
+++ b/src/main/java/org/apache/commons/collections4/SetUtils.java
@@ -81,6 +81,7 @@ public > void copyInto(final S set) {
/**
* Return an iterator for this view; the returned iterator is
* not required to be unmodifiable.
+ *
* @return a new iterator for this view
*/
protected abstract Iterator createIterator();
@@ -479,7 +480,6 @@ public static Set synchronizedSet(final Set set) {
return Collections.synchronizedSet(set);
}
- // SortedSet
/**
* Returns a synchronized sorted set backed by the given sorted set.
*
@@ -644,6 +644,7 @@ public static SortedSet unmodifiableNavigableSet(final NavigableSet se
/**
* Creates an unmodifiable set from the given items. If the passed var-args argument is {@code
* null}, then the method returns {@code null}.
+ *
* @param the element type
* @param items the elements that make up the new set
* @return a set
diff --git a/src/main/java/org/apache/commons/collections4/SortedBidiMap.java b/src/main/java/org/apache/commons/collections4/SortedBidiMap.java
index 5d175aaf08..72cd7e779c 100644
--- a/src/main/java/org/apache/commons/collections4/SortedBidiMap.java
+++ b/src/main/java/org/apache/commons/collections4/SortedBidiMap.java
@@ -56,6 +56,7 @@ public interface SortedBidiMap extends OrderedBidiMap, SortedMap super V> valueComparator();
diff --git a/src/main/java/org/apache/commons/collections4/TransformerUtils.java b/src/main/java/org/apache/commons/collections4/TransformerUtils.java
index 9fd16482ab..3b1bdceabe 100644
--- a/src/main/java/org/apache/commons/collections4/TransformerUtils.java
+++ b/src/main/java/org/apache/commons/collections4/TransformerUtils.java
@@ -40,31 +40,31 @@
* {@code TransformerUtils} provides reference implementations and
* utilities for the Transformer functor interface. The supplied transformers are:
*
- * - Invoker - returns the result of a method call on the input object
- *
- Clone - returns a clone of the input object
- *
- Constant - always returns the same object
- *
- Closure - performs a Closure and returns the input object
- *
- Predicate - returns the result of the predicate as a Boolean
- *
- Factory - returns a new object from a factory
- *
- Chained - chains two or more transformers together
- *
- If - calls one transformer or another based on a predicate
- *
- Switch - calls one transformer based on one or more predicates
- *
- SwitchMap - calls one transformer looked up from a Map
- *
- Instantiate - the Class input object is instantiated
- *
- Map - returns an object from a supplied Map
- *
- Null - always returns null
- *
- NOP - returns the input object, which should be immutable
- *
- Exception - always throws an exception
- *
- StringValue - returns a {@link String} representation of the input object
+ *
- Invoker - returns the result of a method call on the input object
+ * - Clone - returns a clone of the input object
+ * - Constant - always returns the same object
+ * - Closure - performs a Closure and returns the input object
+ * - Predicate - returns the result of the predicate as a Boolean
+ * - Factory - returns a new object from a factory
+ * - Chained - chains two or more transformers together
+ * - If - calls one transformer or another based on a predicate
+ * - Switch - calls one transformer based on one or more predicates
+ * - SwitchMap - calls one transformer looked up from a Map
+ * - Instantiate - the Class input object is instantiated
+ * - Map - returns an object from a supplied Map
+ * - Null - always returns null
+ * - NOP - returns the input object, which should be immutable
+ * - Exception - always throws an exception
+ * - StringValue - returns a {@link String} representation of the input object
*
*
* Since v4.1 only transformers which are considered to be safe are
* Serializable. Transformers considered to be unsafe for serialization are:
*
*
- * - Invoker
- *
- Clone
- *
- Instantiate
+ *
- Invoker
+ * - Clone
+ * - Instantiate
*
*
* @since 3.0
diff --git a/src/main/java/org/apache/commons/collections4/bag/AbstractBagDecorator.java b/src/main/java/org/apache/commons/collections4/bag/AbstractBagDecorator.java
index ea94dd2012..a932fcff2c 100644
--- a/src/main/java/org/apache/commons/collections4/bag/AbstractBagDecorator.java
+++ b/src/main/java/org/apache/commons/collections4/bag/AbstractBagDecorator.java
@@ -38,6 +38,7 @@ public abstract class AbstractBagDecorator
/**
* Constructor only used in deserialization, do not use otherwise.
+ *
* @since 3.1
*/
protected AbstractBagDecorator() {
diff --git a/src/main/java/org/apache/commons/collections4/bag/AbstractMapBag.java b/src/main/java/org/apache/commons/collections4/bag/AbstractMapBag.java
index 4619afc92d..f64d19c933 100644
--- a/src/main/java/org/apache/commons/collections4/bag/AbstractMapBag.java
+++ b/src/main/java/org/apache/commons/collections4/bag/AbstractMapBag.java
@@ -121,6 +121,7 @@ protected static class MutableInteger {
/**
* Constructs a new instance.
+ *
* @param value the initial value
*/
MutableInteger(final int value) {
@@ -479,6 +480,7 @@ public boolean removeAll(final Collection> coll) {
/**
* Remove any members of the bag that are not in the given bag, respecting
* cardinality.
+ *
* @see #retainAll(Collection)
* @param other the bag to retain
* @return {@code true} if this call changed the collection
diff --git a/src/main/java/org/apache/commons/collections4/bag/AbstractSortedBagDecorator.java b/src/main/java/org/apache/commons/collections4/bag/AbstractSortedBagDecorator.java
index d73a5569b0..723fc65f9e 100644
--- a/src/main/java/org/apache/commons/collections4/bag/AbstractSortedBagDecorator.java
+++ b/src/main/java/org/apache/commons/collections4/bag/AbstractSortedBagDecorator.java
@@ -37,6 +37,7 @@ public abstract class AbstractSortedBagDecorator
/**
* Constructor only used in deserialization, do not use otherwise.
+ *
* @since 3.1
*/
protected AbstractSortedBagDecorator() {
diff --git a/src/main/java/org/apache/commons/collections4/bag/SynchronizedBag.java b/src/main/java/org/apache/commons/collections4/bag/SynchronizedBag.java
index 1313f1cc62..ea95fb28ff 100644
--- a/src/main/java/org/apache/commons/collections4/bag/SynchronizedBag.java
+++ b/src/main/java/org/apache/commons/collections4/bag/SynchronizedBag.java
@@ -41,11 +41,13 @@ public class SynchronizedBag extends SynchronizedCollection implements Bag
* Synchronized Set for the Bag class.
*/
final class SynchronizedBagSet extends SynchronizedCollection implements Set {
+
/** Serialization version */
private static final long serialVersionUID = 2990565892366827855L;
/**
* Constructs a new instance.
+ *
* @param set the set to decorate
* @param lock the lock to use, shared with the bag
*/
diff --git a/src/main/java/org/apache/commons/collections4/bag/package-info.java b/src/main/java/org/apache/commons/collections4/bag/package-info.java
index d28e0b1974..cb8284af79 100644
--- a/src/main/java/org/apache/commons/collections4/bag/package-info.java
+++ b/src/main/java/org/apache/commons/collections4/bag/package-info.java
@@ -23,18 +23,18 @@
* The following implementations are provided in the package:
*
*
- * - HashBag - implementation that uses a HashMap to store the data
- *
- TreeBag - implementation that uses a TreeMap to store the data
+ *
- HashBag - implementation that uses a HashMap to store the data
+ * - TreeBag - implementation that uses a TreeMap to store the data
*
*
* The following decorators are provided in the package:
*
*
- * - Synchronized - synchronizes method access for multithreaded environments
- *
- Unmodifiable - ensures the bag cannot be altered
- *
- Predicated - ensures that only elements that are valid according to a predicate can be added
- *
- Transformed - transforms each element added to the bag
- *
- Collection - ensures compliance with the java.util.Collection contract
+ *
- Synchronized - synchronizes method access for multithreaded environments
+ * - Unmodifiable - ensures the bag cannot be altered
+ * - Predicated - ensures that only elements that are valid according to a predicate can be added
+ * - Transformed - transforms each element added to the bag
+ * - Collection - ensures compliance with the java.util.Collection contract
*
*/
package org.apache.commons.collections4.bag;
diff --git a/src/main/java/org/apache/commons/collections4/bidimap/AbstractDualBidiMap.java b/src/main/java/org/apache/commons/collections4/bidimap/AbstractDualBidiMap.java
index 67c20c236c..333179cc4a 100644
--- a/src/main/java/org/apache/commons/collections4/bidimap/AbstractDualBidiMap.java
+++ b/src/main/java/org/apache/commons/collections4/bidimap/AbstractDualBidiMap.java
@@ -67,6 +67,7 @@ protected static class BidiMapIterator implements MapIterator, Reset
/**
* Constructs a new instance.
+ *
* @param parent the parent map
*/
protected BidiMapIterator(final AbstractDualBidiMap parent) {
@@ -210,6 +211,7 @@ protected static class EntrySetIterator extends AbstractIteratorDecorator<
/**
* Constructs a new instance.
+ *
* @param iterator the iterator to decorate
* @param parent the parent map
*/
@@ -298,6 +300,7 @@ protected static class KeySetIterator extends AbstractIteratorDecorator {
/**
* Constructs a new instance.
+ *
* @param iterator the iterator to decorate
* @param parent the parent map
*/
@@ -339,6 +342,7 @@ protected static class MapEntry extends AbstractMapEntryDecorator {
/**
* Constructs a new instance.
+ *
* @param entry the entry to decorate
* @param parent the parent map
*/
@@ -419,6 +423,7 @@ protected static class ValuesIterator extends AbstractIteratorDecorator {
/**
* Constructs a new instance.
+ *
* @param iterator the iterator to decorate
* @param parent the parent map
*/
@@ -742,6 +747,7 @@ public boolean isEmpty() {
}
// Map views
+
/**
* Gets a keySet view of the map.
* Changes made on the view are reflected in the map.
@@ -758,6 +764,7 @@ public Set keySet() {
}
// BidiMap
+
/**
* Obtains a {@code MapIterator} over the map.
* The iterator implements {@link BidiMapIterator}.
diff --git a/src/main/java/org/apache/commons/collections4/bidimap/DualTreeBidiMap.java b/src/main/java/org/apache/commons/collections4/bidimap/DualTreeBidiMap.java
index f539081ca4..e1fcbe5c94 100644
--- a/src/main/java/org/apache/commons/collections4/bidimap/DualTreeBidiMap.java
+++ b/src/main/java/org/apache/commons/collections4/bidimap/DualTreeBidiMap.java
@@ -78,6 +78,7 @@ protected static class BidiOrderedMapIterator implements OrderedMapIterato
/**
* Constructs a new instance.
+ *
* @param parent the parent map
*/
protected BidiOrderedMapIterator(final AbstractDualBidiMap parent) {
@@ -172,8 +173,10 @@ public String toString() {
* @param the type of the values.
*/
protected static class ViewMap extends AbstractSortedMapDecorator {
+
/**
* Constructs a new instance.
+ *
* @param bidi the parent bidi map
* @param sm the subMap sorted map
*/
diff --git a/src/main/java/org/apache/commons/collections4/bidimap/TreeBidiMap.java b/src/main/java/org/apache/commons/collections4/bidimap/TreeBidiMap.java
index c7ed23ff94..f04dcf93a9 100644
--- a/src/main/java/org/apache/commons/collections4/bidimap/TreeBidiMap.java
+++ b/src/main/java/org/apache/commons/collections4/bidimap/TreeBidiMap.java
@@ -95,6 +95,7 @@ abstract class AbstractView extends AbstractSet {
/**
* Constructs a new instance.
+ *
* @param orderType the KEY or VALUE int for the order
*/
AbstractView(final DataElement orderType) {
@@ -119,17 +120,22 @@ abstract class AbstractViewIterator {
/** Whether to return KEY or VALUE order. */
private final DataElement orderType;
+
/** The last node returned by the iterator. */
Node lastReturnedNode;
+
/** The next node to be returned by the iterator. */
private Node nextNode;
+
/** The previous node in the sequence returned by the iterator. */
private Node previousNode;
+
/** The modification count. */
private int expectedModifications;
/**
* Constructs a new instance.
+ *
* @param orderType the KEY or VALUE int for the order
*/
AbstractViewIterator(final DataElement orderType) {
@@ -214,6 +220,7 @@ public String toString() {
return description;
}
}
+
/**
* A view of this map.
*/
@@ -254,6 +261,7 @@ public boolean remove(final Object obj) {
return false;
}
}
+
/**
* The inverse map implementation.
*/
@@ -261,8 +269,10 @@ final class Inverse implements OrderedBidiMap {
/** Store the keySet once created. */
private Set inverseKeySet;
+
/** Store the valuesSet once created. */
private Set inverseValuesSet;
+
/** Store the entrySet once created. */
private Set> inverseEntrySet;
@@ -407,6 +417,7 @@ public Set values() {
return inverseValuesSet;
}
}
+
/**
* A view of this map.
*/
@@ -447,6 +458,7 @@ public boolean remove(final Object obj) {
return false;
}
}
+
/**
* An iterator over the inverse map entries.
*/
@@ -473,6 +485,7 @@ public Map.Entry previous() {
return createEntry(navigatePrevious());
}
}
+
/**
* An iterator over the map.
*/
diff --git a/src/main/java/org/apache/commons/collections4/bidimap/package-info.java b/src/main/java/org/apache/commons/collections4/bidimap/package-info.java
index 28983f2811..3b447054a7 100644
--- a/src/main/java/org/apache/commons/collections4/bidimap/package-info.java
+++ b/src/main/java/org/apache/commons/collections4/bidimap/package-info.java
@@ -27,16 +27,16 @@
* The following implementations are provided in the package:
*
*
- * - DualHashBidiMap - uses two HashMaps to implement BidiMap
- *
- DualLinkedHashBidiMap - uses two LinkedHashMaps to implement BidiMap
- *
- DualTreeBidiMap - uses two TreeMaps to implement SortedBidiMap
- *
- TreeBidiMap - red-black tree implementation of OrderedBidiMap
+ *
- DualHashBidiMap - uses two HashMaps to implement BidiMap
+ * - DualLinkedHashBidiMap - uses two LinkedHashMaps to implement BidiMap
+ * - DualTreeBidiMap - uses two TreeMaps to implement SortedBidiMap
+ * - TreeBidiMap - red-black tree implementation of OrderedBidiMap
*
*
* The following decorators are provided in the package:
*
*
- * - Unmodifiable - ensures the map cannot be altered
+ *
- Unmodifiable - ensures the map cannot be altered
*
*/
package org.apache.commons.collections4.bidimap;
diff --git a/src/main/java/org/apache/commons/collections4/bloomfilter/BitMapExtractor.java b/src/main/java/org/apache/commons/collections4/bloomfilter/BitMapExtractor.java
index 343d6b1338..fcb101e757 100644
--- a/src/main/java/org/apache/commons/collections4/bloomfilter/BitMapExtractor.java
+++ b/src/main/java/org/apache/commons/collections4/bloomfilter/BitMapExtractor.java
@@ -94,6 +94,7 @@ static BitMapExtractor fromIndexExtractor(final IndexExtractor extractor, final
* The default implementation of this method is slow. It is recommended
* that implementing classes reimplement this method.
*
+ *
* @return An array of bit map data.
*/
default long[] asBitMapArray() {
@@ -131,7 +132,7 @@ long[] toArray() {
* arrays reimplement this method.
*
*
- * @param other The other BitMapExtractor that provides the y values in the (x,y) pair.
+ * @param other The other BitMapExtractor that provides the y values in the (x, y) pair.
* @param func The function to apply.
* @return A LongPredicate that tests this BitMapExtractor's bitmap values in order.
*/
diff --git a/src/main/java/org/apache/commons/collections4/bloomfilter/BloomFilter.java b/src/main/java/org/apache/commons/collections4/bloomfilter/BloomFilter.java
index 7f89b26e91..b006e5317c 100644
--- a/src/main/java/org/apache/commons/collections4/bloomfilter/BloomFilter.java
+++ b/src/main/java/org/apache/commons/collections4/bloomfilter/BloomFilter.java
@@ -232,6 +232,7 @@ default int estimateUnion(final BloomFilter> other) {
/**
* Gets the shape that was used when the filter was built.
+ *
* @return The shape the filter was built with.
*/
Shape getShape();
diff --git a/src/main/java/org/apache/commons/collections4/bloomfilter/BloomFilterExtractor.java b/src/main/java/org/apache/commons/collections4/bloomfilter/BloomFilterExtractor.java
index 88a24166e1..a7e27fc0ef 100644
--- a/src/main/java/org/apache/commons/collections4/bloomfilter/BloomFilterExtractor.java
+++ b/src/main/java/org/apache/commons/collections4/bloomfilter/BloomFilterExtractor.java
@@ -120,7 +120,7 @@ default BloomFilter flatten() {
* instances, or references to the filters in the collection.
*
*
- * @param other The other BloomFilterExtractor that provides the y values in the (x,y) pair.
+ * @param other The other BloomFilterExtractor that provides the y values in the (x, y) pair.
* @param func The function to apply.
* @return {@code true} if the {@code func} returned {@code true} for every pair, {@code false} otherwise.
*/
diff --git a/src/main/java/org/apache/commons/collections4/bloomfilter/CellExtractor.java b/src/main/java/org/apache/commons/collections4/bloomfilter/CellExtractor.java
index f6c8e574fc..2536d94b19 100644
--- a/src/main/java/org/apache/commons/collections4/bloomfilter/CellExtractor.java
+++ b/src/main/java/org/apache/commons/collections4/bloomfilter/CellExtractor.java
@@ -51,6 +51,7 @@ public interface CellExtractor extends IndexExtractor {
*/
@FunctionalInterface
interface CellPredicate {
+
/**
* Performs an operation on the given {@code } pair.
*
@@ -70,7 +71,7 @@ interface CellPredicate {
* The CellExtractor aggregates duplicate indices from the IndexExtractor.
*
*
- * A CellExtractor that outputs the mapping [(1,2),(2,3),(3,1)] can be created from many combinations
+ *
A CellExtractor that outputs the mapping [(1, 2),(2, 3),(3, 1)] can be created from many combinations
* of indices including:
*
* [1, 1, 2, 2, 2, 3]
@@ -84,6 +85,7 @@ interface CellPredicate {
*/
static CellExtractor from(final IndexExtractor indexExtractor) {
return new CellExtractor() {
+
/**
* Class to track cell values in the TreeMap.
*/
diff --git a/src/main/java/org/apache/commons/collections4/bloomfilter/CountingBloomFilter.java b/src/main/java/org/apache/commons/collections4/bloomfilter/CountingBloomFilter.java
index cdad5286e6..0a1dbed676 100644
--- a/src/main/java/org/apache/commons/collections4/bloomfilter/CountingBloomFilter.java
+++ b/src/main/java/org/apache/commons/collections4/bloomfilter/CountingBloomFilter.java
@@ -234,6 +234,7 @@ default boolean merge(final Hasher hasher) {
* to a CellExtractor and add that.
* Implementations should throw {@code IllegalArgumentException} and no other exception on bad input.
*
+ *
* @param indexExtractor the IndexExtractor
* @return {@code true} if the removal was successful and the state is valid
* @see #isValid()
@@ -348,6 +349,7 @@ default boolean remove(final IndexExtractor indexExtractor) {
/**
* The default implementation is a no-op since the counting bloom filter returns an unique IndexExtractor by default.
+ *
* @return this counting Bloom filter.
*/
@Override
diff --git a/src/main/java/org/apache/commons/collections4/bloomfilter/IndexFilter.java b/src/main/java/org/apache/commons/collections4/bloomfilter/IndexFilter.java
index a494ee9aa2..646093f298 100644
--- a/src/main/java/org/apache/commons/collections4/bloomfilter/IndexFilter.java
+++ b/src/main/java/org/apache/commons/collections4/bloomfilter/IndexFilter.java
@@ -32,6 +32,7 @@ public final class IndexFilter {
/**
* An IndexTracker implementation that uses an array of integers to track whether or not a
* number has been seen. Suitable for Shapes that have few hash functions.
+ *
* @since 4.5.0
*/
static class ArrayTracker implements IntPredicate {
@@ -40,6 +41,7 @@ static class ArrayTracker implements IntPredicate {
/**
* Constructs the tracker based on the shape.
+ *
* @param shape the shape to build the tracker for.
*/
ArrayTracker(final Shape shape) {
@@ -70,6 +72,7 @@ static class BitMapTracker implements IntPredicate {
/**
* Constructs a bit map based tracker for the specified shape.
+ *
* @param shape The shape that is being generated.
*/
BitMapTracker(final Shape shape) {
diff --git a/src/main/java/org/apache/commons/collections4/bloomfilter/LayerManager.java b/src/main/java/org/apache/commons/collections4/bloomfilter/LayerManager.java
index 1cb64ded8f..7aa9b1c590 100644
--- a/src/main/java/org/apache/commons/collections4/bloomfilter/LayerManager.java
+++ b/src/main/java/org/apache/commons/collections4/bloomfilter/LayerManager.java
@@ -138,7 +138,7 @@ public static > Consumer> noCleanup() {
}
/**
- * Removes the earliest filters in the list when the the number of filters
+ * Removes the earliest filters in the list when the number of filters
* exceeds maxSize.
*
* @param Type of BloomFilter.
@@ -292,7 +292,7 @@ public static > Builder builder() {
/**
* Constructs a new instance.
*
- * @param filterSupplier the non-null supplier of new Bloom filters to add the the list
+ * @param filterSupplier the non-null supplier of new Bloom filters to add the list
* when necessary.
* @param extendCheck The non-null predicate that checks if a new filter should be
* added to the list.
@@ -361,6 +361,7 @@ public LayerManager copy() {
/**
* Gets the Bloom filter from the first layer.
* No extension check is performed during this call.
+ *
* @return The Bloom filter from the first layer.
* @see #getTarget()
*/
diff --git a/src/main/java/org/apache/commons/collections4/bloomfilter/LayeredBloomFilter.java b/src/main/java/org/apache/commons/collections4/bloomfilter/LayeredBloomFilter.java
index b47b9a462c..5d0531c50e 100644
--- a/src/main/java/org/apache/commons/collections4/bloomfilter/LayeredBloomFilter.java
+++ b/src/main/java/org/apache/commons/collections4/bloomfilter/LayeredBloomFilter.java
@@ -45,7 +45,7 @@
*
* - Level 0 is the oldest layer and the highest level is the newest.
* - There is always at least one enclosed filter.
- * - The newest filter is the {@code target} into which merges are performed.
+ *
- The newest filter is the {@code target} into which merges are performed.
* - Whenever the target is retrieved, or a {@code merge} operation is performed the code checks if any older layers should be removed, and if so removes
* them. It also checks it a new layer should be added, and if so adds it and sets the {@code target} before the operation.
*
diff --git a/src/main/java/org/apache/commons/collections4/bloomfilter/LongBiPredicate.java b/src/main/java/org/apache/commons/collections4/bloomfilter/LongBiPredicate.java
index ff2f3b49d7..9d36ed692c 100644
--- a/src/main/java/org/apache/commons/collections4/bloomfilter/LongBiPredicate.java
+++ b/src/main/java/org/apache/commons/collections4/bloomfilter/LongBiPredicate.java
@@ -20,7 +20,7 @@
* Represents a function that accepts a two long-valued argument and produces a binary result.
* This is the long-consuming primitive specialization for {@code BiPredicate}.
*
- * This is a functional interface whose functional method is {@code test(long,long)}.
+ * This is a functional interface whose functional method is {@code test(long, long)}.
*
*
* @since 4.5.0-M1
diff --git a/src/main/java/org/apache/commons/collections4/collection/AbstractCollectionDecorator.java b/src/main/java/org/apache/commons/collections4/collection/AbstractCollectionDecorator.java
index 34ce3d3d70..e764eb5566 100644
--- a/src/main/java/org/apache/commons/collections4/collection/AbstractCollectionDecorator.java
+++ b/src/main/java/org/apache/commons/collections4/collection/AbstractCollectionDecorator.java
@@ -67,6 +67,7 @@ public abstract class AbstractCollectionDecorator
/**
* Constructor only used in deserialization, do not use otherwise.
+ *
* @since 3.1
*/
protected AbstractCollectionDecorator() {
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 1b21ab3332..d89db8d669 100644
--- a/src/main/java/org/apache/commons/collections4/collection/CompositeCollection.java
+++ b/src/main/java/org/apache/commons/collections4/collection/CompositeCollection.java
@@ -37,6 +37,7 @@
* Add and remove operations require the use of a pluggable strategy. If no
* strategy is provided then add and remove are unsupported.
*
+ *
* @param the type of the elements in the collection
* @since 3.0
*/
@@ -228,6 +229,7 @@ public void addComposited(final Collection compositeCollection1,
*
* This implementation calls {@code clear()} on each collection.
*
+ *
* @throws UnsupportedOperationException if clear is unsupported
*/
@Override
@@ -242,6 +244,7 @@ public void clear() {
*
* This implementation calls {@code contains()} on each collection.
*
+ *
* @param obj the object to search for
* @return true if obj is contained in any of the contained collections
*/
@@ -261,6 +264,7 @@ public boolean contains(final Object obj) {
* This implementation calls {@code contains()} for each element in the
* specified collection.
*
+ *
* @param coll the collection to check for
* @return true if all elements contained
*/
@@ -288,6 +292,7 @@ public List> getCollections() {
/**
* Gets the collection mutator to be used for this CompositeCollection.
+ *
* @return CollectionMutator<E>
*/
protected CollectionMutator getMutator() {
@@ -299,6 +304,7 @@ protected CollectionMutator getMutator() {
*
* This implementation calls {@code isEmpty()} on each collection.
*
+ *
* @return true if all of the contained collections are empty
*/
@Override
@@ -316,6 +322,7 @@ public boolean isEmpty() {
*
* This implementation uses an {@code IteratorChain}.
*
+ *
* @return an {@code IteratorChain} instance which supports
* {@code remove()}. Iteration occurs over contained collections in
* the order they were added, but this behavior should not be relied upon.
@@ -356,6 +363,7 @@ public boolean remove(final Object obj) {
*
* This implementation calls {@code removeAll} on each collection.
*
+ *
* @param coll the collection to remove
* @return true if the collection was modified
* @throws UnsupportedOperationException if removeAll is unsupported
@@ -386,6 +394,7 @@ public void removeComposited(final Collection coll) {
*
* This implementation calls {@code removeIf} on each collection.
*
+ *
* @param filter a predicate which returns true for elements to be removed
* @return true if the collection was modified
* @throws UnsupportedOperationException if removeIf is unsupported
@@ -409,6 +418,7 @@ public boolean removeIf(final Predicate super E> filter) {
*
* This implementation calls {@code retainAll()} on each collection.
*
+ *
* @param coll the collection to remove
* @return true if the collection was modified
* @throws UnsupportedOperationException if retainAll is unsupported
@@ -438,6 +448,7 @@ public void setMutator(final CollectionMutator mutator) {
*
* This implementation calls {@code size()} on each collection.
*
+ *
* @return total number of elements in all contained containers
*/
@Override
diff --git a/src/main/java/org/apache/commons/collections4/collection/SynchronizedCollection.java b/src/main/java/org/apache/commons/collections4/collection/SynchronizedCollection.java
index 820727fed5..dbe9d50d9f 100644
--- a/src/main/java/org/apache/commons/collections4/collection/SynchronizedCollection.java
+++ b/src/main/java/org/apache/commons/collections4/collection/SynchronizedCollection.java
@@ -58,6 +58,7 @@ public class SynchronizedCollection implements Collection, Serializable {
public static SynchronizedCollection synchronizedCollection(final Collection coll) {
return new SynchronizedCollection<>(coll);
}
+
/** The collection to decorate */
private final Collection collection;
diff --git a/src/main/java/org/apache/commons/collections4/collection/package-info.java b/src/main/java/org/apache/commons/collections4/collection/package-info.java
index 912a520b1b..6958e97e23 100644
--- a/src/main/java/org/apache/commons/collections4/collection/package-info.java
+++ b/src/main/java/org/apache/commons/collections4/collection/package-info.java
@@ -20,16 +20,19 @@
* {@link java.util.Collection Collection} interface.
*
* The following implementations are provided in the package:
+ *
*
- * - CompositeCollection - a collection that combines multiple collections into one
+ *
- CompositeCollection - a collection that combines multiple collections into one
*
+ *
* The following decorators are provided in the package:
+ *
*
- * - Synchronized - synchronizes method access for multithreaded environments
- *
- Unmodifiable - ensures the collection cannot be altered
- *
- Predicated - ensures that only elements that are valid according to a predicate can be added
- *
- Transformed - transforms elements as they are added
- *
- Indexed - provides a map-like view onto another collection
+ *
- Synchronized - synchronizes method access for multithreaded environments
+ * - Unmodifiable - ensures the collection cannot be altered
+ * - Predicated - ensures that only elements that are valid according to a predicate can be added
+ * - Transformed - transforms elements as they are added
+ * - Indexed - provides a map-like view onto another collection
*
*/
package org.apache.commons.collections4.collection;
diff --git a/src/main/java/org/apache/commons/collections4/comparators/BooleanComparator.java b/src/main/java/org/apache/commons/collections4/comparators/BooleanComparator.java
index aca9fe7bb6..429c1af745 100644
--- a/src/main/java/org/apache/commons/collections4/comparators/BooleanComparator.java
+++ b/src/main/java/org/apache/commons/collections4/comparators/BooleanComparator.java
@@ -176,7 +176,7 @@ public int hashCode() {
* I sort {@code true} values before
* {@code false} values. In other words,
* returns {@code true} iff
- * {@link #compare(Boolean,Boolean) compare(Boolean.FALSE,Boolean.TRUE)}
+ * {@link #compare(Boolean,Boolean) compare(Boolean.FALSE, Boolean.TRUE)}
* returns a positive value.
*
* @return the trueFirst flag
diff --git a/src/main/java/org/apache/commons/collections4/comparators/ComparatorChain.java b/src/main/java/org/apache/commons/collections4/comparators/ComparatorChain.java
index 05fa8acabd..253ddce5b3 100644
--- a/src/main/java/org/apache/commons/collections4/comparators/ComparatorChain.java
+++ b/src/main/java/org/apache/commons/collections4/comparators/ComparatorChain.java
@@ -58,15 +58,17 @@ public class ComparatorChain implements Comparator, Serializable {
/** The list of comparators in the chain. */
private final List> comparatorChain;
+
/** Order - false (clear) = ascend; true (set) = descend. */
private final BitSet orderingBits;
- /** Whether the chain has been "locked". */
+
+ /** Whether the chain has been "locked". */
private boolean isLocked;
/**
* Constructs a ComparatorChain with no Comparators.
* You must add at least one Comparator before calling
- * the compare(Object,Object) method, or an
+ * the compare(Object, Object) method, or an
* UnsupportedOperationException is thrown
*/
public ComparatorChain() {
@@ -182,7 +184,7 @@ private void checkLocked() {
/**
* Perform comparisons on the Objects as per
- * Comparator.compare(o1,o2).
+ * Comparator.compare(o1, o2).
*
* @param o1 the first object to compare
* @param o2 the second object to compare
diff --git a/src/main/java/org/apache/commons/collections4/comparators/FixedOrderComparator.java b/src/main/java/org/apache/commons/collections4/comparators/FixedOrderComparator.java
index 42490a70f0..fa9b3a25a6 100644
--- a/src/main/java/org/apache/commons/collections4/comparators/FixedOrderComparator.java
+++ b/src/main/java/org/apache/commons/collections4/comparators/FixedOrderComparator.java
@@ -90,7 +90,6 @@ public enum UnknownObjectBehavior {
/** The behavior in the case of an unknown object */
private UnknownObjectBehavior unknownObjectBehavior = UnknownObjectBehavior.EXCEPTION;
- // Constructors
/**
* Constructs an empty FixedOrderComparator.
*/
@@ -127,7 +126,6 @@ public FixedOrderComparator(final T... items) {
}
}
- // Methods for adding items
/**
* Adds an item, which compares as after all items known to the Comparator.
* If the item is already known to the Comparator, its old position is
@@ -178,7 +176,6 @@ protected void checkLocked() {
}
}
- // Comparator methods
/**
* Compares two objects according to the order of this Comparator.
*
@@ -245,7 +242,6 @@ public int hashCode() {
return Objects.hash(counter, isLocked, map, unknownObjectBehavior);
}
- // Bean methods / state querying methods
/**
* Returns true if modifications cannot be made to the FixedOrderComparator.
* FixedOrderComparators cannot be modified once they have performed a comparison.
diff --git a/src/main/java/org/apache/commons/collections4/comparators/NullComparator.java b/src/main/java/org/apache/commons/collections4/comparators/NullComparator.java
index 882fc9fc50..b38c6203b1 100644
--- a/src/main/java/org/apache/commons/collections4/comparators/NullComparator.java
+++ b/src/main/java/org/apache/commons/collections4/comparators/NullComparator.java
@@ -35,99 +35,96 @@ public class NullComparator implements Comparator, Serializable {
private static final long serialVersionUID = -5820772575483504339L;
/**
- * The comparator to use when comparing two non-{@code null} objects.
- **/
+ * The comparator to use when comparing two non-{@code null} objects.
+ */
private final Comparator super E> nonNullComparator;
/**
- * Specifies whether a {@code null} are compared as higher than
- * non-{@code null} objects.
- **/
+ * Specifies whether a {@code null} are compared as higher than
+ * non-{@code null} objects.
+ */
private final boolean nullsAreHigh;
/**
- * Construct an instance that sorts {@code null} higher than any
- * non-{@code null} object it is compared with. When comparing two
- * non-{@code null} objects, the {@link ComparableComparator} is
- * used.
- **/
+ * Construct an instance that sorts {@code null} higher than any
+ * non-{@code null} object it is compared with. When comparing two
+ * non-{@code null} objects, the {@link ComparableComparator} is
+ * used.
+ */
public NullComparator() {
this(ComparatorUtils.NATURAL_COMPARATOR, true);
}
/**
- * Construct an instance that sorts {@code null} higher or lower than
- * any non-{@code null} object it is compared with. When comparing
- * two non-{@code null} objects, the {@link ComparableComparator} is
- * used.
+ * Construct an instance that sorts {@code null} higher or lower than
+ * any non-{@code null} object it is compared with. When comparing
+ * two non-{@code null} objects, the {@link ComparableComparator} is
+ * used.
*
- * @param nullsAreHigh a {@code true} value indicates that
- * {@code null} should be compared as higher than a
- * non-{@code null} object. A {@code false} value indicates
- * that {@code null} should be compared as lower than a
- * non-{@code null} object.
- **/
+ * @param nullsAreHigh a {@code true} value indicates that
+ * {@code null} should be compared as higher than a
+ * non-{@code null} object. A {@code false} value indicates
+ * that {@code null} should be compared as lower than a
+ * non-{@code null} object.
+ */
public NullComparator(final boolean nullsAreHigh) {
this(ComparatorUtils.NATURAL_COMPARATOR, nullsAreHigh);
}
/**
- * Construct an instance that sorts {@code null} higher than any
- * non-{@code null} object it is compared with. When comparing two
- * non-{@code null} objects, the specified {@link Comparator} is
- * used.
+ * Construct an instance that sorts {@code null} higher than any
+ * non-{@code null} object it is compared with. When comparing two
+ * non-{@code null} objects, the specified {@link Comparator} is
+ * used.
*
- * @param nonNullComparator the comparator to use when comparing two
- * non-{@code null} objects. This argument cannot be
- * {@code null}
- *
- * @throws NullPointerException if {@code nonNullComparator} is
- * {@code null}
- **/
+ * @param nonNullComparator the comparator to use when comparing two
+ * non-{@code null} objects. This argument cannot be
+ * {@code null}
+ * @throws NullPointerException if {@code nonNullComparator} is
+ * {@code null}
+ */
public NullComparator(final Comparator super E> nonNullComparator) {
this(nonNullComparator, true);
}
/**
- * Construct an instance that sorts {@code null} higher or lower than
- * any non-{@code null} object it is compared with. When comparing
- * two non-{@code null} objects, the specified {@link Comparator} is
- * used.
- *
- * @param nonNullComparator the comparator to use when comparing two
- * non-{@code null} objects. This argument cannot be
- * {@code null}
+ * Construct an instance that sorts {@code null} higher or lower than
+ * any non-{@code null} object it is compared with. When comparing
+ * two non-{@code null} objects, the specified {@link Comparator} is
+ * used.
*
- * @param nullsAreHigh a {@code true} value indicates that
- * {@code null} should be compared as higher than a
- * non-{@code null} object. A {@code false} value indicates
- * that {@code null} should be compared as lower than a
- * non-{@code null} object.
- *
- * @throws NullPointerException if {@code nonNullComparator} is
- * {@code null}
- **/
+ * @param nonNullComparator the comparator to use when comparing two
+ * non-{@code null} objects. This argument cannot be
+ * {@code null}
+ * @param nullsAreHigh a {@code true} value indicates that
+ * {@code null} should be compared as higher than a
+ * non-{@code null} object. A {@code false} value indicates
+ * that {@code null} should be compared as lower than a
+ * non-{@code null} object.
+ * @throws NullPointerException if {@code nonNullComparator} is
+ * {@code null}
+ */
public NullComparator(final Comparator super E> nonNullComparator, final boolean nullsAreHigh) {
this.nonNullComparator = Objects.requireNonNull(nonNullComparator, "nonNullComparator");
this.nullsAreHigh = nullsAreHigh;
}
/**
- * Perform a comparison between two objects. If both objects are
- * {@code null}, a {@code 0} value is returned. If one object
- * is {@code null} and the other is not, the result is determined on
- * whether the Comparator was constructed to have nulls as higher or lower
- * than other objects. If neither object is {@code null}, an
- * underlying comparator specified in the constructor (or the default) is
- * used to compare the non-{@code null} objects.
+ * Perform a comparison between two objects. If both objects are
+ * {@code null}, a {@code 0} value is returned. If one object
+ * is {@code null} and the other is not, the result is determined on
+ * whether the Comparator was constructed to have nulls as higher or lower
+ * than other objects. If neither object is {@code null}, an
+ * underlying comparator specified in the constructor (or the default) is
+ * used to compare the non-{@code null} objects.
*
- * @param o1 the first object to compare
- * @param o2 the object to compare it to.
- * @return {@code -1} if {@code o1} is "lower" than (less than,
- * before, etc.) {@code o2}; {@code 1} if {@code o1} is
- * "higher" than (greater than, after, etc.) {@code o2}; or
- * {@code 0} if {@code o1} and {@code o2} are equal.
- **/
+ * @param o1 the first object to compare
+ * @param o2 the object to compare it to.
+ * @return {@code -1} if {@code o1} is "lower" than (less than,
+ * before, etc.) {@code o2}; {@code 1} if {@code o1} is
+ * "higher" than (greater than, after, etc.) {@code o2}; or
+ * {@code 0} if {@code o1} and {@code o2} are equal.
+ */
@Override
public int compare(final E o1, final E o2) {
if (o1 == o2) {
@@ -143,16 +140,15 @@ public int compare(final E o1, final E o2) {
}
/**
- * Determines whether the specified object represents a comparator that is
- * equal to this comparator.
- *
- * @param obj the object to compare this comparator with.
+ * Determines whether the specified object represents a comparator that is
+ * equal to this comparator.
*
- * @return {@code true} if the specified object is a NullComparator
- * with equivalent {@code null} comparison behavior
- * (i.e. {@code null} high or low) and with equivalent underlying
- * non-{@code null} object comparators.
- **/
+ * @param obj the object to compare this comparator with.
+ * @return {@code true} if the specified object is a NullComparator
+ * with equivalent {@code null} comparison behavior
+ * (i.e. {@code null} high or low) and with equivalent underlying
+ * non-{@code null} object comparators.
+ */
@Override
public boolean equals(final Object obj) {
if (obj == null) {
@@ -172,11 +168,11 @@ public boolean equals(final Object obj) {
}
/**
- * Implement a hash code for this comparator that is consistent with
- * {@link #equals(Object)}.
+ * Implement a hash code for this comparator that is consistent with
+ * {@link #equals(Object)}.
*
- * @return a hash code for this comparator.
- **/
+ * @return a hash code for this comparator.
+ */
@Override
public int hashCode() {
return (nullsAreHigh ? -1 : 1) * nonNullComparator.hashCode();
diff --git a/src/main/java/org/apache/commons/collections4/functors/AbstractPredicate.java b/src/main/java/org/apache/commons/collections4/functors/AbstractPredicate.java
index 5b7e409173..d091bd6321 100644
--- a/src/main/java/org/apache/commons/collections4/functors/AbstractPredicate.java
+++ b/src/main/java/org/apache/commons/collections4/functors/AbstractPredicate.java
@@ -19,7 +19,7 @@
import org.apache.commons.collections4.Predicate;
/**
- * Abstract base class for predicates.
+ * Abstract class for predicates.
*
* @param the type of the input to the predicate.
* @since 4.5.0-M3
diff --git a/src/main/java/org/apache/commons/collections4/functors/AbstractQuantifierPredicate.java b/src/main/java/org/apache/commons/collections4/functors/AbstractQuantifierPredicate.java
index c8b902aa04..062799ddfb 100644
--- a/src/main/java/org/apache/commons/collections4/functors/AbstractQuantifierPredicate.java
+++ b/src/main/java/org/apache/commons/collections4/functors/AbstractQuantifierPredicate.java
@@ -21,7 +21,7 @@
import org.apache.commons.collections4.Predicate;
/**
- * Abstract base class for quantification predicates, for example All, Any, None.
+ * Abstract class for quantification predicates, for example All, Any, None.
*
* @param the type of the input to the predicate.
* @since 4.0
diff --git a/src/main/java/org/apache/commons/collections4/functors/AndPredicate.java b/src/main/java/org/apache/commons/collections4/functors/AndPredicate.java
index 40d8896ef9..5c21374510 100644
--- a/src/main/java/org/apache/commons/collections4/functors/AndPredicate.java
+++ b/src/main/java/org/apache/commons/collections4/functors/AndPredicate.java
@@ -46,6 +46,7 @@ public static Predicate andPredicate(final Predicate super T> predicate
return new AndPredicate<>(Objects.requireNonNull(predicate1, "predicate1"),
Objects.requireNonNull(predicate2, "predicate2"));
}
+
/** The array of predicates to call */
private final Predicate super T> iPredicate1;
diff --git a/src/main/java/org/apache/commons/collections4/functors/ForClosure.java b/src/main/java/org/apache/commons/collections4/functors/ForClosure.java
index 67eb9d0aa8..8fc4f58011 100644
--- a/src/main/java/org/apache/commons/collections4/functors/ForClosure.java
+++ b/src/main/java/org/apache/commons/collections4/functors/ForClosure.java
@@ -53,6 +53,7 @@ public static Closure forClosure(final int count, final Closure super E
}
return new ForClosure<>(count, closure);
}
+
/** The number of times to loop */
private final int iCount;
diff --git a/src/main/java/org/apache/commons/collections4/functors/IfClosure.java b/src/main/java/org/apache/commons/collections4/functors/IfClosure.java
index 964f16d900..54072b79bc 100644
--- a/src/main/java/org/apache/commons/collections4/functors/IfClosure.java
+++ b/src/main/java/org/apache/commons/collections4/functors/IfClosure.java
@@ -50,6 +50,7 @@ public class IfClosure implements Closure, Serializable {
public static Closure ifClosure(final Predicate super E> predicate, final Closure super E> trueClosure) {
return IfClosure.ifClosure(predicate, trueClosure, NOPClosure.nopClosure());
}
+
/**
* Factory method that performs validation.
*
@@ -67,6 +68,7 @@ public static Closure ifClosure(final Predicate super E> predicate,
Objects.requireNonNull(trueClosure, "trueClosure"),
Objects.requireNonNull(falseClosure, "falseClosure"));
}
+
/** The test */
private final Predicate super T> iPredicate;
diff --git a/src/main/java/org/apache/commons/collections4/functors/IfTransformer.java b/src/main/java/org/apache/commons/collections4/functors/IfTransformer.java
index 97e0c21716..7743c5337a 100644
--- a/src/main/java/org/apache/commons/collections4/functors/IfTransformer.java
+++ b/src/main/java/org/apache/commons/collections4/functors/IfTransformer.java
@@ -53,6 +53,7 @@ public static Transformer ifTransformer(final Predicate super I>
Objects.requireNonNull(trueTransformer, "trueTransformer"),
Objects.requireNonNull(falseTransformer, "falseTransformer"));
}
+
/**
* Factory method that performs validation.
*
@@ -71,6 +72,7 @@ public static Transformer ifTransformer(
return new IfTransformer<>(Objects.requireNonNull(predicate, "predicate"),
Objects.requireNonNull(trueTransformer, "trueTransformer"), NOPTransformer.nopTransformer());
}
+
/** The test */
private final Predicate super T> iPredicate;
diff --git a/src/main/java/org/apache/commons/collections4/functors/InstantiateFactory.java b/src/main/java/org/apache/commons/collections4/functors/InstantiateFactory.java
index cb263f6f15..e8f2d22756 100644
--- a/src/main/java/org/apache/commons/collections4/functors/InstantiateFactory.java
+++ b/src/main/java/org/apache/commons/collections4/functors/InstantiateFactory.java
@@ -63,10 +63,13 @@ public static Factory instantiateFactory(final Class classToInstantiat
}
return new InstantiateFactory<>(classToInstantiate, paramTypes, args);
}
+
/** The class to create */
private final Class iClassToInstantiate;
+
/** The constructor parameter types */
private final Class>[] iParamTypes;
+
/** The constructor arguments */
private final Object[] iArgs;
diff --git a/src/main/java/org/apache/commons/collections4/functors/InstantiateTransformer.java b/src/main/java/org/apache/commons/collections4/functors/InstantiateTransformer.java
index e1c3f09869..18361e5c19 100644
--- a/src/main/java/org/apache/commons/collections4/functors/InstantiateTransformer.java
+++ b/src/main/java/org/apache/commons/collections4/functors/InstantiateTransformer.java
@@ -49,6 +49,7 @@ public class InstantiateTransformer implements Transformer extends T>
public static Transformer extends T>, T> instantiateTransformer() {
return NO_ARG_INSTANCE;
}
+
/**
* Transformer method that performs validation.
*
diff --git a/src/main/java/org/apache/commons/collections4/functors/InvokerTransformer.java b/src/main/java/org/apache/commons/collections4/functors/InvokerTransformer.java
index f24cea644e..263a306d09 100644
--- a/src/main/java/org/apache/commons/collections4/functors/InvokerTransformer.java
+++ b/src/main/java/org/apache/commons/collections4/functors/InvokerTransformer.java
@@ -51,6 +51,7 @@ public class InvokerTransformer implements Transformer {
public static Transformer invokerTransformer(final String methodName) {
return new InvokerTransformer<>(Objects.requireNonNull(methodName, "methodName"));
}
+
/**
* Gets an instance of this transformer calling a specific method with specific values.
*
@@ -76,6 +77,7 @@ public static Transformer invokerTransformer(final String methodNam
}
return new InvokerTransformer<>(methodName, paramTypes, args);
}
+
/** The method name to call */
private final String iMethodName;
diff --git a/src/main/java/org/apache/commons/collections4/functors/OrPredicate.java b/src/main/java/org/apache/commons/collections4/functors/OrPredicate.java
index 4576cc85bb..92572a5831 100644
--- a/src/main/java/org/apache/commons/collections4/functors/OrPredicate.java
+++ b/src/main/java/org/apache/commons/collections4/functors/OrPredicate.java
@@ -46,6 +46,7 @@ public static Predicate orPredicate(final Predicate super T> predicate1
return new OrPredicate<>(Objects.requireNonNull(predicate1, "predicate1"),
Objects.requireNonNull(predicate2, "predicate2"));
}
+
/** The array of predicates to call */
private final Predicate super T> iPredicate1;
diff --git a/src/main/java/org/apache/commons/collections4/functors/PrototypeFactory.java b/src/main/java/org/apache/commons/collections4/functors/PrototypeFactory.java
index 5333dbec44..5c1fada974 100644
--- a/src/main/java/org/apache/commons/collections4/functors/PrototypeFactory.java
+++ b/src/main/java/org/apache/commons/collections4/functors/PrototypeFactory.java
@@ -51,6 +51,7 @@ static class PrototypeCloneFactory implements Factory {
/** The object to clone each time */
private final T iPrototype;
+
/** The method used to clone */
private transient Method iCloneMethod;
diff --git a/src/main/java/org/apache/commons/collections4/functors/SwitchClosure.java b/src/main/java/org/apache/commons/collections4/functors/SwitchClosure.java
index a63c67c225..2d20c1ad15 100644
--- a/src/main/java/org/apache/commons/collections4/functors/SwitchClosure.java
+++ b/src/main/java/org/apache/commons/collections4/functors/SwitchClosure.java
@@ -72,6 +72,7 @@ public static Closure switchClosure(final Map, Closure> p
}
return new SwitchClosure<>(false, preds, closures, defaultClosure);
}
+
/**
* Factory method that performs validation and copies the parameter arrays.
*
@@ -98,6 +99,7 @@ public static Closure switchClosure(final Predicate super E>[] predicat
}
return new SwitchClosure<>(predicates, closures, defaultClosure);
}
+
/** The tests to consider */
private final Predicate super T>[] iPredicates;
diff --git a/src/main/java/org/apache/commons/collections4/functors/SwitchTransformer.java b/src/main/java/org/apache/commons/collections4/functors/SwitchTransformer.java
index a73a7fe4f0..213d1d5b95 100644
--- a/src/main/java/org/apache/commons/collections4/functors/SwitchTransformer.java
+++ b/src/main/java/org/apache/commons/collections4/functors/SwitchTransformer.java
@@ -81,6 +81,7 @@ public static Transformer switchTransformer(
}
return new SwitchTransformer<>(false, preds, transformers, defaultTransformer);
}
+
/**
* Factory method that performs validation and copies the parameter arrays.
*
@@ -109,6 +110,7 @@ public static Transformer switchTransformer(final Predicate super
}
return new SwitchTransformer<>(predicates, transformers, defaultTransformer);
}
+
/** The tests to consider */
private final Predicate super T>[] iPredicates;
diff --git a/src/main/java/org/apache/commons/collections4/functors/WhileClosure.java b/src/main/java/org/apache/commons/collections4/functors/WhileClosure.java
index 84b235f3b0..cd9f984f58 100644
--- a/src/main/java/org/apache/commons/collections4/functors/WhileClosure.java
+++ b/src/main/java/org/apache/commons/collections4/functors/WhileClosure.java
@@ -51,8 +51,10 @@ public static Closure whileClosure(final Predicate super E> predicate,
return new WhileClosure<>(Objects.requireNonNull(predicate, "predicate"),
Objects.requireNonNull(closure, "closure"), doLoop);
}
+
/** The test condition */
private final Predicate super T> iPredicate;
+
/** The closure to call */
private final Closure super T> iClosure;
diff --git a/src/main/java/org/apache/commons/collections4/iterators/ArrayIterator.java b/src/main/java/org/apache/commons/collections4/iterators/ArrayIterator.java
index f972cdf27a..b19a8ec53c 100644
--- a/src/main/java/org/apache/commons/collections4/iterators/ArrayIterator.java
+++ b/src/main/java/org/apache/commons/collections4/iterators/ArrayIterator.java
@@ -41,10 +41,13 @@ public class ArrayIterator implements ResettableIterator {
/** The array to iterate over */
final Object array;
+
/** The start index to loop from */
final int startIndex;
+
/** The end index to loop to */
final int endIndex;
+
/** The current iterator index */
int index;
diff --git a/src/main/java/org/apache/commons/collections4/iterators/BoundedIterator.java b/src/main/java/org/apache/commons/collections4/iterators/BoundedIterator.java
index 73d3b2f316..300910b442 100644
--- a/src/main/java/org/apache/commons/collections4/iterators/BoundedIterator.java
+++ b/src/main/java/org/apache/commons/collections4/iterators/BoundedIterator.java
@@ -82,6 +82,7 @@ public BoundedIterator(final Iterator extends E> iterator, final long offset,
/**
* Checks whether the iterator is still within its bounded range.
+ *
* @return {@code true} if the iterator is within its bounds, {@code false} otherwise
*/
private boolean checkBounds() {
diff --git a/src/main/java/org/apache/commons/collections4/iterators/EmptyMapIterator.java b/src/main/java/org/apache/commons/collections4/iterators/EmptyMapIterator.java
index 52265fec20..1aac23f18b 100644
--- a/src/main/java/org/apache/commons/collections4/iterators/EmptyMapIterator.java
+++ b/src/main/java/org/apache/commons/collections4/iterators/EmptyMapIterator.java
@@ -30,6 +30,7 @@ public class EmptyMapIterator extends AbstractEmptyMapIterator imple
/**
* Singleton instance of the iterator.
+ *
* @since 3.1
*/
@SuppressWarnings("rawtypes")
@@ -37,6 +38,7 @@ public class EmptyMapIterator extends AbstractEmptyMapIterator imple
/**
* Gets a typed instance of the iterator.
+ *
* @param the key type
* @param the value type
* @return {@link MapIterator}<K, V>
diff --git a/src/main/java/org/apache/commons/collections4/iterators/EmptyOrderedMapIterator.java b/src/main/java/org/apache/commons/collections4/iterators/EmptyOrderedMapIterator.java
index 0ee07de620..b3e0fb4de7 100644
--- a/src/main/java/org/apache/commons/collections4/iterators/EmptyOrderedMapIterator.java
+++ b/src/main/java/org/apache/commons/collections4/iterators/EmptyOrderedMapIterator.java
@@ -30,6 +30,7 @@ public class EmptyOrderedMapIterator extends AbstractEmptyMapIterator extends AbstractEmptyMapIterator the key type
* @param the value type
* @return {@link OrderedMapIterator}<K, V>
diff --git a/src/main/java/org/apache/commons/collections4/iterators/EnumerationIterator.java b/src/main/java/org/apache/commons/collections4/iterators/EnumerationIterator.java
index 95333b4078..9a83e7ebfc 100644
--- a/src/main/java/org/apache/commons/collections4/iterators/EnumerationIterator.java
+++ b/src/main/java/org/apache/commons/collections4/iterators/EnumerationIterator.java
@@ -31,12 +31,13 @@ public class EnumerationIterator implements Iterator {
/** The collection to remove elements from */
private final Collection super E> collection;
+
/** The enumeration being converted */
private Enumeration extends E> enumeration;
+
/** The last object retrieved */
private E last;
- // Constructors
/**
* Constructs a new {@code EnumerationIterator} that will not
* function until {@link #setEnumeration(Enumeration)} is called.
@@ -77,7 +78,6 @@ public Enumeration extends E> getEnumeration() {
return enumeration;
}
- // Iterator interface
/**
* Returns true if the underlying enumeration has more elements.
*
diff --git a/src/main/java/org/apache/commons/collections4/iterators/FilterListIterator.java b/src/main/java/org/apache/commons/collections4/iterators/FilterListIterator.java
index 7a2e88b72b..67fb422c49 100644
--- a/src/main/java/org/apache/commons/collections4/iterators/FilterListIterator.java
+++ b/src/main/java/org/apache/commons/collections4/iterators/FilterListIterator.java
@@ -109,6 +109,7 @@ public FilterListIterator(final Predicate super E> predicate) {
/**
* Not supported.
+ *
* @param o the element to insert
*/
@Override
@@ -194,6 +195,7 @@ public void remove() {
/**
* Not supported.
+ *
* @param ignored the element with which to replace the last element returned by
* {@code next} or {@code previous}
*/
diff --git a/src/main/java/org/apache/commons/collections4/iterators/IteratorChain.java b/src/main/java/org/apache/commons/collections4/iterators/IteratorChain.java
index 19ed92d6a6..031fb650c0 100644
--- a/src/main/java/org/apache/commons/collections4/iterators/IteratorChain.java
+++ b/src/main/java/org/apache/commons/collections4/iterators/IteratorChain.java
@@ -69,7 +69,7 @@ public class IteratorChain implements Iterator {
private Iterator extends E> lastUsedIterator;
/**
- * ComparatorChain is "locked" after the first time compare(Object,Object)
+ * ComparatorChain is "locked" after the first time compare(Object, Object)
* is called
*/
private boolean isLocked;
diff --git a/src/main/java/org/apache/commons/collections4/iterators/ListIteratorWrapper.java b/src/main/java/org/apache/commons/collections4/iterators/ListIteratorWrapper.java
index 3d227940a8..dbba4b722f 100644
--- a/src/main/java/org/apache/commons/collections4/iterators/ListIteratorWrapper.java
+++ b/src/main/java/org/apache/commons/collections4/iterators/ListIteratorWrapper.java
@@ -60,13 +60,16 @@ public class ListIteratorWrapper implements ResettableListIterator {
/** The underlying iterator being decorated. */
private final Iterator extends E> iterator;
+
/** The list being used to cache the iterator. */
private final List list = new ArrayList<>();
/** The current index of this iterator. */
private int currentIndex;
+
/** The current index of the wrapped iterator. */
private int wrappedIteratorIndex;
+
/** Recall whether the wrapped iterator's "cursor" is in such a state as to allow remove() to be called */
private boolean removeState;
diff --git a/src/main/java/org/apache/commons/collections4/iterators/LoopingIterator.java b/src/main/java/org/apache/commons/collections4/iterators/LoopingIterator.java
index 31fb99dc6c..0bcdea5ee6 100644
--- a/src/main/java/org/apache/commons/collections4/iterators/LoopingIterator.java
+++ b/src/main/java/org/apache/commons/collections4/iterators/LoopingIterator.java
@@ -42,6 +42,7 @@ public class LoopingIterator implements ResettableIterator {
/** The collection to base the iterator on */
private final Collection extends E> collection;
+
/** The current iterator */
private Iterator extends E> iterator;
diff --git a/src/main/java/org/apache/commons/collections4/iterators/LoopingListIterator.java b/src/main/java/org/apache/commons/collections4/iterators/LoopingListIterator.java
index 0c47deecc9..1f76ddf046 100644
--- a/src/main/java/org/apache/commons/collections4/iterators/LoopingListIterator.java
+++ b/src/main/java/org/apache/commons/collections4/iterators/LoopingListIterator.java
@@ -44,6 +44,7 @@ public class LoopingListIterator implements ResettableListIterator {
/** The list to base the iterator on */
private final List list;
+
/** The current list iterator */
private ListIterator iterator;
diff --git a/src/main/java/org/apache/commons/collections4/iterators/NodeListIterator.java b/src/main/java/org/apache/commons/collections4/iterators/NodeListIterator.java
index 82f4682d9d..916eeab927 100644
--- a/src/main/java/org/apache/commons/collections4/iterators/NodeListIterator.java
+++ b/src/main/java/org/apache/commons/collections4/iterators/NodeListIterator.java
@@ -37,6 +37,7 @@ public class NodeListIterator implements Iterator {
/** The original NodeList instance */
private final NodeList nodeList;
+
/** The current iterator index */
private int index;
diff --git a/src/main/java/org/apache/commons/collections4/iterators/ObjectArrayIterator.java b/src/main/java/org/apache/commons/collections4/iterators/ObjectArrayIterator.java
index c45909d942..2c0d82631f 100644
--- a/src/main/java/org/apache/commons/collections4/iterators/ObjectArrayIterator.java
+++ b/src/main/java/org/apache/commons/collections4/iterators/ObjectArrayIterator.java
@@ -38,10 +38,13 @@ public class ObjectArrayIterator implements ResettableIterator {
/** The array */
final E[] array;
+
/** The start index to loop from */
final int startIndex;
+
/** The end index to loop to */
final int endIndex;
+
/** The current iterator index */
int index;
diff --git a/src/main/java/org/apache/commons/collections4/iterators/ObjectGraphIterator.java b/src/main/java/org/apache/commons/collections4/iterators/ObjectGraphIterator.java
index 2cc1f1a195..daae6e426a 100644
--- a/src/main/java/org/apache/commons/collections4/iterators/ObjectGraphIterator.java
+++ b/src/main/java/org/apache/commons/collections4/iterators/ObjectGraphIterator.java
@@ -84,17 +84,22 @@ public class ObjectGraphIterator implements Iterator {
/** The stack of iterators */
private final Deque extends E>> stack = new ArrayDeque<>(8);
+
/** The root object in the tree */
private E root;
+
/** The transformer to use */
private final Transformer super E, ? extends E> transformer;
/** Whether there is another element in the iteration */
private boolean hasNext;
+
/** The current iterator */
private Iterator extends E> currentIterator;
+
/** The current value */
private E currentValue;
+
/** The last used iterator, needed for remove() */
private Iterator extends E> lastUsedIterator;
diff --git a/src/main/java/org/apache/commons/collections4/iterators/PermutationIterator.java b/src/main/java/org/apache/commons/collections4/iterators/PermutationIterator.java
index 542cdae0d0..6aace66579 100644
--- a/src/main/java/org/apache/commons/collections4/iterators/PermutationIterator.java
+++ b/src/main/java/org/apache/commons/collections4/iterators/PermutationIterator.java
@@ -71,6 +71,7 @@ public class PermutationIterator implements Iterator> {
/**
* Standard constructor for this class.
+ *
* @param collection the collection to generate permutations for
* @throws NullPointerException if coll is null
*/
@@ -91,6 +92,7 @@ public PermutationIterator(final Collection extends E> collection) {
/**
* Indicates if there are more permutation available.
+ *
* @return true if there are more permutations, otherwise false
*/
@Override
@@ -100,6 +102,7 @@ public boolean hasNext() {
/**
* Returns the next permutation of the input collection.
+ *
* @return a list of the permutator's elements representing a permutation
* @throws NoSuchElementException if there are no more permutations
*/
diff --git a/src/main/java/org/apache/commons/collections4/iterators/ReverseListIterator.java b/src/main/java/org/apache/commons/collections4/iterators/ReverseListIterator.java
index 287bdf5b7f..921c66f09a 100644
--- a/src/main/java/org/apache/commons/collections4/iterators/ReverseListIterator.java
+++ b/src/main/java/org/apache/commons/collections4/iterators/ReverseListIterator.java
@@ -42,8 +42,10 @@ public class ReverseListIterator implements ResettableListIterator {
/** The list being wrapped. */
private final List list;
+
/** The list iterator being wrapped. */
private ListIterator iterator;
+
/** Flag to indicate if updating is possible at the moment. */
private boolean validForUpdate = true;
diff --git a/src/main/java/org/apache/commons/collections4/iterators/SingletonIterator.java b/src/main/java/org/apache/commons/collections4/iterators/SingletonIterator.java
index 87dd8d19d2..49b4fb6872 100644
--- a/src/main/java/org/apache/commons/collections4/iterators/SingletonIterator.java
+++ b/src/main/java/org/apache/commons/collections4/iterators/SingletonIterator.java
@@ -32,10 +32,13 @@ public class SingletonIterator
/** Whether remove is allowed */
private final boolean removeAllowed;
+
/** Is the cursor before the first element */
private boolean beforeFirst = true;
+
/** Has the element been removed */
private boolean removed;
+
/** The object */
private E object;
diff --git a/src/main/java/org/apache/commons/collections4/iterators/SingletonListIterator.java b/src/main/java/org/apache/commons/collections4/iterators/SingletonListIterator.java
index 6496e41a79..53529a98b2 100644
--- a/src/main/java/org/apache/commons/collections4/iterators/SingletonListIterator.java
+++ b/src/main/java/org/apache/commons/collections4/iterators/SingletonListIterator.java
@@ -140,6 +140,7 @@ public int previousIndex() {
/**
* Remove the object from this iterator.
+ *
* @throws IllegalStateException if the {@code next} or {@code previous}
* method has not yet been called, or the {@code remove} method
* has already been called after the last call to {@code next}
diff --git a/src/main/java/org/apache/commons/collections4/iterators/TransformIterator.java b/src/main/java/org/apache/commons/collections4/iterators/TransformIterator.java
index 36dc0b9f1c..f7b4113fd7 100644
--- a/src/main/java/org/apache/commons/collections4/iterators/TransformIterator.java
+++ b/src/main/java/org/apache/commons/collections4/iterators/TransformIterator.java
@@ -31,6 +31,7 @@ public class TransformIterator implements Iterator {
/** The iterator being used */
private Iterator extends I> iterator;
+
/** The transformer being used */
private Transformer super I, ? extends O> transformer;
diff --git a/src/main/java/org/apache/commons/collections4/iterators/UniqueFilterIterator.java b/src/main/java/org/apache/commons/collections4/iterators/UniqueFilterIterator.java
index 88eadd41ca..7370b1bd57 100644
--- a/src/main/java/org/apache/commons/collections4/iterators/UniqueFilterIterator.java
+++ b/src/main/java/org/apache/commons/collections4/iterators/UniqueFilterIterator.java
@@ -31,9 +31,9 @@
public class UniqueFilterIterator extends FilterIterator {
/**
- * Constructs a new {@code UniqueFilterIterator}.
+ * Constructs a new {@code UniqueFilterIterator}.
*
- * @param iterator the iterator to use
+ * @param iterator the iterator to use
*/
public UniqueFilterIterator(final Iterator extends E> iterator) {
super(iterator, UniquePredicate.uniquePredicate());
diff --git a/src/main/java/org/apache/commons/collections4/keyvalue/AbstractKeyValue.java b/src/main/java/org/apache/commons/collections4/keyvalue/AbstractKeyValue.java
index 24bdd55675..4a602681a4 100644
--- a/src/main/java/org/apache/commons/collections4/keyvalue/AbstractKeyValue.java
+++ b/src/main/java/org/apache/commons/collections4/keyvalue/AbstractKeyValue.java
@@ -30,6 +30,7 @@ public abstract class AbstractKeyValue implements KeyValue {
/** The key */
private K key;
+
/** The value */
private V value;
diff --git a/src/main/java/org/apache/commons/collections4/keyvalue/MultiKey.java b/src/main/java/org/apache/commons/collections4/keyvalue/MultiKey.java
index 4515372d23..dcc621eb3b 100644
--- a/src/main/java/org/apache/commons/collections4/keyvalue/MultiKey.java
+++ b/src/main/java/org/apache/commons/collections4/keyvalue/MultiKey.java
@@ -233,6 +233,7 @@ public MultiKey(final K[] keys, final boolean makeClone) {
/**
* Calculate the hash code of the instance using the provided keys.
+ *
* @param keys the keys to calculate the hash code for
*/
private void calculateHashCode(final Object[] keys) {
@@ -316,6 +317,7 @@ public int hashCode() {
* Recalculate the hash code after deserialization. The hash code of some
* keys might have change (hash codes based on the system hash code are
* only stable for the same process).
+ *
* @return the instance with recalculated hash code
*/
protected Object readResolve() {
diff --git a/src/main/java/org/apache/commons/collections4/keyvalue/package-info.java b/src/main/java/org/apache/commons/collections4/keyvalue/package-info.java
index f6f305feb6..4a1b204464 100644
--- a/src/main/java/org/apache/commons/collections4/keyvalue/package-info.java
+++ b/src/main/java/org/apache/commons/collections4/keyvalue/package-info.java
@@ -20,10 +20,11 @@
* These are usually used in maps, however they can be used as data holders in any collection.
*
* The following key/value designs are included:
+ *
*
- * - Map Entry - various map entry implementations
- *
- KeyValue - a key and value pair, without map entry semantics
- *
- MultiKey - a holder of multiple keys tied together
+ *
- Map Entry - various map entry implementations
+ * - KeyValue - a key and value pair, without map entry semantics
+ * - MultiKey - a holder of multiple keys tied together
*
*/
package org.apache.commons.collections4.keyvalue;
diff --git a/src/main/java/org/apache/commons/collections4/list/AbstractLinkedList.java b/src/main/java/org/apache/commons/collections4/list/AbstractLinkedList.java
index ab18d7b032..fe9e30ea2f 100644
--- a/src/main/java/org/apache/commons/collections4/list/AbstractLinkedList.java
+++ b/src/main/java/org/apache/commons/collections4/list/AbstractLinkedList.java
@@ -438,8 +438,10 @@ protected static class Node {
/** A pointer to the node before this node */
protected Node previous;
+
/** A pointer to the node after this node */
protected Node next;
+
/** The object contained within this node */
protected E value;
diff --git a/src/main/java/org/apache/commons/collections4/list/AbstractLinkedListJava21.java b/src/main/java/org/apache/commons/collections4/list/AbstractLinkedListJava21.java
index e2a7c52e2a..7a79d4dc3f 100644
--- a/src/main/java/org/apache/commons/collections4/list/AbstractLinkedListJava21.java
+++ b/src/main/java/org/apache/commons/collections4/list/AbstractLinkedListJava21.java
@@ -229,12 +229,16 @@ public void set(final E obj) {
* @param the type of elements in this list.
*/
protected static class LinkedSubList extends AbstractList {
+
/** The main list */
AbstractLinkedListJava21 parent;
+
/** Offset from the main list */
int offset;
+
/** Sublist size */
int size;
+
/** Sublist modCount */
int expectedModCount;
@@ -437,8 +441,10 @@ protected static class Node {
/** A pointer to the node before this node */
protected Node previous;
+
/** A pointer to the node after this node */
protected Node next;
+
/** The object contained within this node */
protected E value;
diff --git a/src/main/java/org/apache/commons/collections4/list/AbstractListDecorator.java b/src/main/java/org/apache/commons/collections4/list/AbstractListDecorator.java
index 25ecf62669..ee85167de5 100644
--- a/src/main/java/org/apache/commons/collections4/list/AbstractListDecorator.java
+++ b/src/main/java/org/apache/commons/collections4/list/AbstractListDecorator.java
@@ -38,6 +38,7 @@ public abstract class AbstractListDecorator extends AbstractCollectionDecorat
/**
* Constructor only used in deserialization, do not use otherwise.
+ *
* @since 3.1
*/
protected AbstractListDecorator() {
diff --git a/src/main/java/org/apache/commons/collections4/list/CursorableLinkedList.java b/src/main/java/org/apache/commons/collections4/list/CursorableLinkedList.java
index df080a21e5..c8e231b4c4 100644
--- a/src/main/java/org/apache/commons/collections4/list/CursorableLinkedList.java
+++ b/src/main/java/org/apache/commons/collections4/list/CursorableLinkedList.java
@@ -70,10 +70,13 @@ public class CursorableLinkedList extends AbstractLinkedList implements Se
* @param the type of elements in this cursor.
*/
public static class Cursor extends AbstractLinkedList.LinkedListIterator {
+
/** Is the cursor valid (not closed) */
boolean valid = true;
+
/** Is the next index valid */
boolean nextIndexValid = true;
+
/** Flag to indicate if the current element was removed by another object. */
boolean currentRemovedByAnother;
diff --git a/src/main/java/org/apache/commons/collections4/list/TreeList.java b/src/main/java/org/apache/commons/collections4/list/TreeList.java
index 5bedb5cd1b..57c15b24ef 100644
--- a/src/main/java/org/apache/commons/collections4/list/TreeList.java
+++ b/src/main/java/org/apache/commons/collections4/list/TreeList.java
@@ -33,7 +33,7 @@
* A {@code List} implementation that is optimized for fast insertions and
* removals at any index in the list.
*
- * This list implementation utilises a tree structure internally to ensure that
+ * This list implementation utilizes a tree structure internally to ensure that
* all insertions and removals are O(log n). This provides much faster performance
* than both an {@code ArrayList} and a {@code LinkedList} where elements
* are inserted and removed repeatedly from anywhere in the list.
@@ -76,23 +76,32 @@ public class TreeList extends AbstractList {
* The nodes don't know the index of the object they are holding. They
* do know however their position relative to their parent node.
* This allows to calculate the index of a node while traversing the tree.
+ *
*
* The Faedelung calculation stores a flag for both the left and right child
* to indicate if they are a child (false) or a link as in linked list (true).
+ *
*/
static class AVLNode {
+
/** The left child node or the predecessor if {@link #leftIsPrevious}.*/
private AVLNode left;
+
/** Flag indicating that left reference is not a subtree but the predecessor. */
private boolean leftIsPrevious;
+
/** The right child node or the successor if {@link #rightIsNext}. */
private AVLNode right;
+
/** Flag indicating that right reference is not a subtree but the successor. */
private boolean rightIsNext;
+
/** How many levels of left/right are below this one. */
private int height;
+
/** The relative position, root holds absolute position. */
private int relativePosition;
+
/** The stored element. */
private E value;
@@ -132,6 +141,7 @@ private AVLNode(final int relativePosition, final E obj,
* to this method will construct the subtree for elements {@code start}
* through {@code end} of the collection, assuming the iterator
* {@code e} already points at element {@code start}.
+ *
*
* @param iterator an iterator over the collection, which should already point
* to the element at index {@code start} within the collection
@@ -754,25 +764,31 @@ public String toString() {
* A list iterator over the linked list.
*/
static class TreeListIterator implements ListIterator, OrderedIterator {
+
/** The parent list */
private final TreeList parent;
+
/**
* Cache of the next node that will be returned by {@link #next()}.
*/
private AVLNode next;
+
/**
* The index of the next node to be returned.
*/
private int nextIndex;
+
/**
* Cache of the last node that was returned by {@link #next()}
* or {@link #previous()}.
*/
private AVLNode current;
+
/**
* The index of the last node that was returned.
*/
private int currentIndex;
+
/**
* The modification count that the list is expected to have. If the list
* doesn't have this count, then a
@@ -788,6 +804,7 @@ static class TreeListIterator implements ListIterator, OrderedIterator
* @param fromIndex the index to start at
*/
protected TreeListIterator(final TreeList parent, final int fromIndex) {
+ checkInterval(fromIndex, 0, parent.size(), parent.size());
this.parent = parent;
this.expectedModCount = parent.modCount;
this.next = parent.root == null ? null : parent.root.get(fromIndex);
@@ -900,6 +917,21 @@ public void set(final E obj) {
}
}
+ /**
+ * Checks whether the index is valid.
+ *
+ * @param index the index to check.
+ * @param startIndex the first allowed index.
+ * @param endIndex the last allowed index.
+ * @param endIndex the size.
+ * @throws IndexOutOfBoundsException if the index is invalid
+ */
+ private static void checkInterval(final int index, final int startIndex, final int endIndex, final int size) {
+ if (index < startIndex || index > endIndex) {
+ throw new IndexOutOfBoundsException("Invalid index:" + index + ", size=" + size);
+ }
+ }
+
/** The root node in the AVL tree */
private AVLNode root;
@@ -949,6 +981,7 @@ public void add(final int index, final E obj) {
*
* This method runs in O(n + log m) time, where m is
* the size of this list and n is the size of {@code c}.
+ *
*
* @param c the collection to be added to this list
* @return {@code true} if this list changed as a result of the call
@@ -977,9 +1010,7 @@ public boolean addAll(final Collection extends E> c) {
* @throws IndexOutOfBoundsException if the index is invalid
*/
private void checkInterval(final int index, final int startIndex, final int endIndex) {
- if (index < startIndex || index > endIndex) {
- throw new IndexOutOfBoundsException("Invalid index:" + index + ", size=" + size());
- }
+ checkInterval(index, startIndex, endIndex, size());
}
/**
@@ -1055,14 +1086,13 @@ public ListIterator listIterator() {
/**
* Gets a ListIterator over the list.
*
- * @param fromIndex the index to start from
- * @return the new iterator
+ * @param fromIndex the index to start from.
+ * @return the new iterator.
*/
@Override
public ListIterator listIterator(final int fromIndex) {
// override to go 75% faster
// cannot use EmptyIterator as iterator.add() must work
- checkInterval(fromIndex, 0, size());
return new TreeListIterator<>(this, fromIndex);
}
diff --git a/src/main/java/org/apache/commons/collections4/map/AbstractHashedMap.java b/src/main/java/org/apache/commons/collections4/map/AbstractHashedMap.java
index 683072cc82..aee103d8b7 100644
--- a/src/main/java/org/apache/commons/collections4/map/AbstractHashedMap.java
+++ b/src/main/java/org/apache/commons/collections4/map/AbstractHashedMap.java
@@ -235,6 +235,7 @@ public String toString() {
return new StringBuilder().append(getKey()).append('=').append(getValue()).toString();
}
}
+
/**
* Base Iterator.
*
diff --git a/src/main/java/org/apache/commons/collections4/map/AbstractLinkedMap.java b/src/main/java/org/apache/commons/collections4/map/AbstractLinkedMap.java
index 4473831a57..4f17657fba 100644
--- a/src/main/java/org/apache/commons/collections4/map/AbstractLinkedMap.java
+++ b/src/main/java/org/apache/commons/collections4/map/AbstractLinkedMap.java
@@ -140,8 +140,10 @@ public K previous() {
* @param the value type.
*/
protected static class LinkEntry extends HashEntry {
+
/** The entry before this one in the order */
protected LinkEntry before;
+
/** The entry after this one in the order */
protected LinkEntry after;
diff --git a/src/main/java/org/apache/commons/collections4/map/AbstractMapDecorator.java b/src/main/java/org/apache/commons/collections4/map/AbstractMapDecorator.java
index 5047b1ac76..ffcae5ee29 100644
--- a/src/main/java/org/apache/commons/collections4/map/AbstractMapDecorator.java
+++ b/src/main/java/org/apache/commons/collections4/map/AbstractMapDecorator.java
@@ -47,6 +47,7 @@ public abstract class AbstractMapDecorator extends AbstractIterableMap extends AbstractMapDecor
/**
* Constructor only used in deserialization, do not use otherwise.
+ *
* @since 3.1
*/
protected AbstractOrderedMapDecorator() {
diff --git a/src/main/java/org/apache/commons/collections4/map/AbstractReferenceMap.java b/src/main/java/org/apache/commons/collections4/map/AbstractReferenceMap.java
index 3b08521555..42f84c2942 100644
--- a/src/main/java/org/apache/commons/collections4/map/AbstractReferenceMap.java
+++ b/src/main/java/org/apache/commons/collections4/map/AbstractReferenceMap.java
@@ -94,6 +94,7 @@ public abstract class AbstractReferenceMap extends AbstractHashedMap
* Base iterator class.
*/
static class ReferenceBaseIterator {
+
/** The parent map */
final AbstractReferenceMap parent;
@@ -197,6 +198,7 @@ public void remove() {
* @since 3.1
*/
protected static class ReferenceEntry extends HashEntry {
+
/** The parent map */
private final AbstractReferenceMap parent;
@@ -309,6 +311,7 @@ protected void onPurge() {
/**
* Purges the specified reference
+ *
* @param ref the reference to purge
* @return true or false
*/
@@ -517,6 +520,7 @@ public enum ReferenceStrength {
/**
* Resolve enum from int.
+ *
* @param value the int value
* @return ReferenceType
* @throws IllegalArgumentException if the specified value is invalid.
@@ -586,6 +590,7 @@ public V next() {
* A soft reference holder.
*/
static class SoftRef extends SoftReference {
+
/** The hashCode of the key (even if the reference points to a value) */
private final int hash;
@@ -619,6 +624,7 @@ public int hashCode() {
* A weak reference holder.
*/
static class WeakRef extends WeakReference {
+
/** The hashCode of the key (even if the reference points to a value) */
private final int hash;
diff --git a/src/main/java/org/apache/commons/collections4/map/AbstractSortedMapDecorator.java b/src/main/java/org/apache/commons/collections4/map/AbstractSortedMapDecorator.java
index 78a49ef6a1..75a6d7dca3 100644
--- a/src/main/java/org/apache/commons/collections4/map/AbstractSortedMapDecorator.java
+++ b/src/main/java/org/apache/commons/collections4/map/AbstractSortedMapDecorator.java
@@ -59,6 +59,7 @@ protected static class SortedMapIterator extends EntrySetToMapIteratorAdap
/**
* Create a new AbstractSortedMapDecorator.SortedMapIterator.
+ *
* @param entrySet the entrySet to iterate
*/
protected SortedMapIterator(final Set> entrySet) {
@@ -94,6 +95,7 @@ public synchronized void reset() {
/**
* Constructor only used in deserialization, do not use otherwise.
+ *
* @since 3.1
*/
protected AbstractSortedMapDecorator() {
diff --git a/src/main/java/org/apache/commons/collections4/map/CompositeMap.java b/src/main/java/org/apache/commons/collections4/map/CompositeMap.java
index 9c26db3f33..8161d6cb1f 100644
--- a/src/main/java/org/apache/commons/collections4/map/CompositeMap.java
+++ b/src/main/java/org/apache/commons/collections4/map/CompositeMap.java
@@ -56,6 +56,7 @@ public class CompositeMap extends AbstractIterableMap implements Ser
* @param the type of the values in the map
*/
public interface MapMutator extends Serializable {
+
/**
* Called when the CompositeMap.put() method is invoked.
*
diff --git a/src/main/java/org/apache/commons/collections4/map/ConcurrentReferenceHashMap.java b/src/main/java/org/apache/commons/collections4/map/ConcurrentReferenceHashMap.java
index 78a5bc9f5b..c7cdea3950 100644
--- a/src/main/java/org/apache/commons/collections4/map/ConcurrentReferenceHashMap.java
+++ b/src/main/java/org/apache/commons/collections4/map/ConcurrentReferenceHashMap.java
@@ -622,9 +622,10 @@ public int size() {
}
/**
- * Behavior-changing configuration options for the map
+ * Enumerates eehavior-changing configuration options for the map.
*/
public enum Option {
+
/**
* Indicates that referential-equality (== instead of .equals()) should be used when locating keys. This offers similar behavior to
* {@link IdentityHashMap}
@@ -633,17 +634,20 @@ public enum Option {
}
/**
- * An option specifying which Java reference type should be used to refer to a key and/or value.
+ * Enumerates which Java reference type should be used to refer to a key and/or value.
*/
public enum ReferenceType {
+
/**
* Indicates a normal Java strong reference should be used
*/
STRONG,
+
/**
* Indicates a {@link WeakReference} should be used
*/
WEAK,
+
/**
* Indicates a {@link SoftReference} should be used
*/
diff --git a/src/main/java/org/apache/commons/collections4/map/EntrySetToMapIteratorAdapter.java b/src/main/java/org/apache/commons/collections4/map/EntrySetToMapIteratorAdapter.java
index 3f9d57ee3d..636e14d9e6 100644
--- a/src/main/java/org/apache/commons/collections4/map/EntrySetToMapIteratorAdapter.java
+++ b/src/main/java/org/apache/commons/collections4/map/EntrySetToMapIteratorAdapter.java
@@ -43,6 +43,7 @@ public class EntrySetToMapIteratorAdapter implements MapIterator, Re
/**
* Create a new EntrySetToMapIteratorAdapter.
+ *
* @param entrySet the entrySet to adapt
*/
public EntrySetToMapIteratorAdapter(final Set> entrySet) {
@@ -52,6 +53,7 @@ public EntrySetToMapIteratorAdapter(final Set> entrySet) {
/**
* Gets the currently active entry.
+ *
* @return Map.Entry<K, V>
*/
protected synchronized Map.Entry current() {
diff --git a/src/main/java/org/apache/commons/collections4/map/Flat3Map.java b/src/main/java/org/apache/commons/collections4/map/Flat3Map.java
index f9d7dbaec8..1d68fe033a 100644
--- a/src/main/java/org/apache/commons/collections4/map/Flat3Map.java
+++ b/src/main/java/org/apache/commons/collections4/map/Flat3Map.java
@@ -44,11 +44,11 @@
* It also has good garbage collection characteristics.
*
*
- * - Optimized for operation at size 3 or less.
- *
- Still works well once size 3 exceeded.
- *
- Gets at size 3 or less are about 0-10% faster than HashMap,
- *
- Puts at size 3 or less are over 4 times faster than HashMap.
- *
- Performance 5% slower than HashMap once size 3 exceeded once.
+ *
- Optimized for operation at size 3 or less.
+ * - Still works well once size 3 exceeded.
+ * - Gets at size 3 or less are about 0-10% faster than HashMap,
+ * - Puts at size 3 or less are over 4 times faster than HashMap.
+ * - Performance 5% slower than HashMap once size 3 exceeded once.
*
*
* The design uses two distinct modes of operation - flat and delegate.
@@ -161,6 +161,7 @@ public int size() {
return parent.size();
}
}
+
/**
* EntrySetIterator and MapEntry
*/
diff --git a/src/main/java/org/apache/commons/collections4/map/LRUMap.java b/src/main/java/org/apache/commons/collections4/map/LRUMap.java
index 73ae5c539f..feecbe44c8 100644
--- a/src/main/java/org/apache/commons/collections4/map/LRUMap.java
+++ b/src/main/java/org/apache/commons/collections4/map/LRUMap.java
@@ -68,11 +68,13 @@ public class LRUMap
/** Serialization version */
private static final long serialVersionUID = -612114643488955218L;
+
/** Default maximum size */
protected static final int DEFAULT_MAX_SIZE = 100;
/** Maximum size */
private transient int maxSize;
+
/** Scan behavior */
private final boolean scanUntilRemovable;
diff --git a/src/main/java/org/apache/commons/collections4/map/MultiKeyMap.java b/src/main/java/org/apache/commons/collections4/map/MultiKeyMap.java
index 7bb9e50f89..0882943fdb 100644
--- a/src/main/java/org/apache/commons/collections4/map/MultiKeyMap.java
+++ b/src/main/java/org/apache/commons/collections4/map/MultiKeyMap.java
@@ -50,9 +50,9 @@
* enables extra behavior to be added easily.
*
*
- * - {@code MultiKeyMap.decorate(new LinkedMap())} creates an ordered map.
- *
- {@code MultiKeyMap.decorate(new LRUMap())} creates an least recently used map.
- *
- {@code MultiKeyMap.decorate(new ReferenceMap())} creates a garbage collector sensitive map.
+ *
- {@code MultiKeyMap.decorate(new LinkedMap())} creates an ordered map.
+ * - {@code MultiKeyMap.decorate(new LRUMap())} creates an least recently used map.
+ * - {@code MultiKeyMap.decorate(new ReferenceMap())} creates a garbage collector sensitive map.
*
*
* Note that {@code IdentityMap} and {@code ReferenceIdentityMap} are unsuitable
diff --git a/src/main/java/org/apache/commons/collections4/map/MultiValueMap.java b/src/main/java/org/apache/commons/collections4/map/MultiValueMap.java
index c1756e3fa9..7d3cd3c8d2 100644
--- a/src/main/java/org/apache/commons/collections4/map/MultiValueMap.java
+++ b/src/main/java/org/apache/commons/collections4/map/MultiValueMap.java
@@ -135,6 +135,7 @@ public int size() {
return totalSize();
}
}
+
/**
* Inner class that provides the values iterator.
*/
@@ -471,9 +472,9 @@ public boolean putAll(final K key, final Collection values) {
* correctly handled.
*
* If you call this method with a normal map, each entry is
- * added using {@code put(Object,Object)}.
+ * added using {@code put(Object, Object)}.
* If you call this method with a multi map, each entry is
- * added using {@code putAll(Object,Collection)}.
+ * added using {@code putAll(Object, Collection)}.
*
*
* @param map the map to copy (either a normal or multi map)
diff --git a/src/main/java/org/apache/commons/collections4/map/SingletonMap.java b/src/main/java/org/apache/commons/collections4/map/SingletonMap.java
index dff5a199b5..a9f3fc8fbd 100644
--- a/src/main/java/org/apache/commons/collections4/map/SingletonMap.java
+++ b/src/main/java/org/apache/commons/collections4/map/SingletonMap.java
@@ -52,9 +52,9 @@
* The key and value can be obtained by:
*
*
- * - normal Map methods and views
- *
- the {@code MapIterator}, see {@link #mapIterator()}
- *
- the {@code KeyValue} interface (just cast - no object creation)
+ *
- normal Map methods and views
+ * - the {@code MapIterator}, see {@link #mapIterator()}
+ * - the {@code KeyValue} interface (just cast - no object creation)
*
*
* @param the type of the keys in this map
@@ -183,6 +183,7 @@ public int size() {
return 1;
}
}
+
/** Serialization version */
private static final long serialVersionUID = -8931271118676803261L;
@@ -336,7 +337,6 @@ public K firstKey() {
return getKey();
}
- // Map
/**
* Gets the value mapped to the key specified.
*
@@ -351,7 +351,6 @@ public V get(final Object key) {
return null;
}
- // KeyValue
/**
* Gets the key.
*
@@ -413,7 +412,6 @@ protected boolean isEqualValue(final Object value) {
return Objects.equals(value, getValue());
}
- // BoundedMap
/**
* Is the map currently full, always true.
*
diff --git a/src/main/java/org/apache/commons/collections4/map/TransformedMap.java b/src/main/java/org/apache/commons/collections4/map/TransformedMap.java
index d358f29539..6dcd47d879 100644
--- a/src/main/java/org/apache/commons/collections4/map/TransformedMap.java
+++ b/src/main/java/org/apache/commons/collections4/map/TransformedMap.java
@@ -84,6 +84,7 @@ public static TransformedMap transformedMap(final Map map,
}
return decorated;
}
+
/**
* Factory method to create a transforming map.
*
diff --git a/src/main/java/org/apache/commons/collections4/map/package-info.java b/src/main/java/org/apache/commons/collections4/map/package-info.java
index 84364141c3..c70baf0915 100644
--- a/src/main/java/org/apache/commons/collections4/map/package-info.java
+++ b/src/main/java/org/apache/commons/collections4/map/package-info.java
@@ -25,29 +25,31 @@
* simple iteration of map keys and values.
*
* The following implementations are provided:
+ *
*
- * - CaseInsensitiveMap - map that compares keys in a case insensitive way
- *
- CompositeMap - map that combines multiple maps into a single view
- *
- HashedMap - general purpose HashMap replacement supporting MapIterator
- *
- Flat3Map - designed for good performance at size 3 or less
- *
- LinkedMap - a hash map that maintains insertion order, supporting OrderedMapIterator
- *
- LRUMap - a hash map that maintains a maximum size by removing the least recently used entries
- *
- MultiKeyMap - map that provides special methods for using more than one key to access the value
- *
- ReferenceMap - allows the garbage collector to collect keys and values using equals() for comparison
- *
- ReferenceIdentityMap - allows the garbage collector to collect keys and values using == for comparison
- *
- SingletonMap - a fully featured map to hold one key-value pair
- *
- StaticBucketMap - internally synchronized and designed for thread-contentious environments
+ *
- CaseInsensitiveMap - map that compares keys in a case insensitive way
+ * - CompositeMap - map that combines multiple maps into a single view
+ * - HashedMap - general purpose HashMap replacement supporting MapIterator
+ * - Flat3Map - designed for good performance at size 3 or less
+ * - LinkedMap - a hash map that maintains insertion order, supporting OrderedMapIterator
+ * - LRUMap - a hash map that maintains a maximum size by removing the least recently used entries
+ * - MultiKeyMap - map that provides special methods for using more than one key to access the value
+ * - ReferenceMap - allows the garbage collector to collect keys and values using equals() for comparison
+ * - ReferenceIdentityMap - allows the garbage collector to collect keys and values using == for comparison
+ * - SingletonMap - a fully featured map to hold one key-value pair
+ * - StaticBucketMap - internally synchronized and designed for thread-contentious environments
*
*
* The following decorators are provided:
+ *
*
- * - Unmodifiable - ensures the collection cannot be altered
- *
- Predicated - ensures that only elements that are valid according to a predicate can be added
- *
- Transformed - transforms each element added
- *
- FixedSize - ensures that the size of the map cannot change
- *
- Defaulted - provides default values for non-existing keys
- *
- Lazy - creates objects in the map on demand
- *
- ListOrdered - ensures that insertion order is retained
+ *
- Unmodifiable - ensures the collection cannot be altered
+ * - Predicated - ensures that only elements that are valid according to a predicate can be added
+ * - Transformed - transforms each element added
+ * - FixedSize - ensures that the size of the map cannot change
+ * - Defaulted - provides default values for non-existing keys
+ * - Lazy - creates objects in the map on demand
+ * - ListOrdered - ensures that insertion order is retained
*
*/
package org.apache.commons.collections4.map;
diff --git a/src/main/java/org/apache/commons/collections4/multimap/AbstractListValuedMap.java b/src/main/java/org/apache/commons/collections4/multimap/AbstractListValuedMap.java
index f14371f9bc..de34ee31bb 100644
--- a/src/main/java/org/apache/commons/collections4/multimap/AbstractListValuedMap.java
+++ b/src/main/java/org/apache/commons/collections4/multimap/AbstractListValuedMap.java
@@ -242,6 +242,7 @@ protected AbstractListValuedMap(final Map> map) {
/**
* Creates a new value collection using the provided factory.
+ *
* @return a new list
*/
@Override
diff --git a/src/main/java/org/apache/commons/collections4/multimap/AbstractSetValuedMap.java b/src/main/java/org/apache/commons/collections4/multimap/AbstractSetValuedMap.java
index 5f3b940cf4..ff98ea2b75 100644
--- a/src/main/java/org/apache/commons/collections4/multimap/AbstractSetValuedMap.java
+++ b/src/main/java/org/apache/commons/collections4/multimap/AbstractSetValuedMap.java
@@ -87,6 +87,7 @@ protected AbstractSetValuedMap(final Map> map) {
/**
* Creates a new value collection using the provided factory.
+ *
* @return a new set
*/
@Override
diff --git a/src/main/java/org/apache/commons/collections4/multimap/ArrayListValuedHashMap.java b/src/main/java/org/apache/commons/collections4/multimap/ArrayListValuedHashMap.java
index a9d2a11537..47586dc631 100644
--- a/src/main/java/org/apache/commons/collections4/multimap/ArrayListValuedHashMap.java
+++ b/src/main/java/org/apache/commons/collections4/multimap/ArrayListValuedHashMap.java
@@ -25,6 +25,7 @@
import java.util.HashMap;
import java.util.Map;
+import org.apache.commons.collections4.MultiMapUtils;
import org.apache.commons.collections4.MultiValuedMap;
/**
@@ -118,6 +119,11 @@ protected ArrayList createCollection() {
return new ArrayList<>(initialListCapacity);
}
+ @Override
+ public ArrayListValuedHashMap inverted() {
+ return MultiMapUtils.invert(this, new ArrayListValuedHashMap());
+ }
+
/**
* Deserializes an instance from an ObjectInputStream.
*
diff --git a/src/main/java/org/apache/commons/collections4/multimap/ArrayListValuedLinkedHashMap.java b/src/main/java/org/apache/commons/collections4/multimap/ArrayListValuedLinkedHashMap.java
index f1b797b532..2556ab3f74 100644
--- a/src/main/java/org/apache/commons/collections4/multimap/ArrayListValuedLinkedHashMap.java
+++ b/src/main/java/org/apache/commons/collections4/multimap/ArrayListValuedLinkedHashMap.java
@@ -25,6 +25,7 @@
import java.util.LinkedHashMap;
import java.util.Map;
+import org.apache.commons.collections4.MultiMapUtils;
import org.apache.commons.collections4.MultiValuedMap;
/**
@@ -118,6 +119,11 @@ protected ArrayList createCollection() {
return new ArrayList<>(initialListCapacity);
}
+ @Override
+ public ArrayListValuedLinkedHashMap inverted() {
+ return MultiMapUtils.invert(this, new ArrayListValuedLinkedHashMap<>());
+ }
+
/**
* Deserializes an instance from an ObjectInputStream.
*
diff --git a/src/main/java/org/apache/commons/collections4/multimap/HashSetValuedHashMap.java b/src/main/java/org/apache/commons/collections4/multimap/HashSetValuedHashMap.java
index b122e2c410..184730cbfb 100644
--- a/src/main/java/org/apache/commons/collections4/multimap/HashSetValuedHashMap.java
+++ b/src/main/java/org/apache/commons/collections4/multimap/HashSetValuedHashMap.java
@@ -24,6 +24,7 @@
import java.util.HashSet;
import java.util.Map;
+import org.apache.commons.collections4.MultiMapUtils;
import org.apache.commons.collections4.MultiValuedMap;
/**
@@ -117,6 +118,11 @@ protected HashSet createCollection() {
return new HashSet<>(initialSetCapacity);
}
+ @Override
+ public HashSetValuedHashMap inverted() {
+ return MultiMapUtils.invert(this, new HashSetValuedHashMap());
+ }
+
/**
* Deserializes an instance from an ObjectInputStream.
*
diff --git a/src/main/java/org/apache/commons/collections4/multimap/LinkedHashSetValuedLinkedHashMap.java b/src/main/java/org/apache/commons/collections4/multimap/LinkedHashSetValuedLinkedHashMap.java
index c8be8751dc..c381893b6a 100644
--- a/src/main/java/org/apache/commons/collections4/multimap/LinkedHashSetValuedLinkedHashMap.java
+++ b/src/main/java/org/apache/commons/collections4/multimap/LinkedHashSetValuedLinkedHashMap.java
@@ -24,6 +24,7 @@
import java.util.LinkedHashSet;
import java.util.Map;
+import org.apache.commons.collections4.MultiMapUtils;
import org.apache.commons.collections4.MultiValuedMap;
/**
@@ -117,6 +118,11 @@ protected LinkedHashSet createCollection() {
return new LinkedHashSet<>(initialSetCapacity);
}
+ @Override
+ public LinkedHashSetValuedLinkedHashMap inverted() {
+ return MultiMapUtils.invert(this, new LinkedHashSetValuedLinkedHashMap());
+ }
+
/**
* Deserializes an instance from an ObjectInputStream.
*
diff --git a/src/main/java/org/apache/commons/collections4/multimap/package-info.java b/src/main/java/org/apache/commons/collections4/multimap/package-info.java
index 85cb3686c9..4936635078 100644
--- a/src/main/java/org/apache/commons/collections4/multimap/package-info.java
+++ b/src/main/java/org/apache/commons/collections4/multimap/package-info.java
@@ -20,15 +20,17 @@
* A MultiValuedMap holds a collection of values against each key.
*
* The following implementations are provided in the package:
+ *
*
- * - ArrayListValuedHashMap - ListValuedMap implementation using a HashMap/ArrayList
- *
- HashSetValuedHashMap - SetValuedMap implementation using a HashMap/HashSet
+ *
- ArrayListValuedHashMap - ListValuedMap implementation using a HashMap/ArrayList
+ * - HashSetValuedHashMap - SetValuedMap implementation using a HashMap/HashSet
*
*
* The following decorators are provided in the package:
+ *
*
- * - Transformed - transforms elements added to the MultiValuedMap
- *
- Unmodifiable - ensures the collection cannot be altered
+ *
- Transformed - transforms elements added to the MultiValuedMap
+ * - Unmodifiable - ensures the collection cannot be altered
*
*/
package org.apache.commons.collections4.multimap;
diff --git a/src/main/java/org/apache/commons/collections4/multiset/AbstractMapMultiSet.java b/src/main/java/org/apache/commons/collections4/multiset/AbstractMapMultiSet.java
index 19e7f620c3..0e24a6e167 100644
--- a/src/main/java/org/apache/commons/collections4/multiset/AbstractMapMultiSet.java
+++ b/src/main/java/org/apache/commons/collections4/multiset/AbstractMapMultiSet.java
@@ -64,6 +64,7 @@ protected static class EntrySetIterator implements Iterator> {
/**
* Constructs a new instance.
+ *
* @param decorated the iterator to decorate
* @param parent the parent multiset
*/
@@ -95,6 +96,7 @@ public void remove() {
canRemove = false;
}
}
+
/**
* Inner class iterator for the MultiSet.
*/
@@ -174,6 +176,7 @@ protected static class MultiSetEntry extends AbstractEntry {
/**
* Constructs a new instance.
+ *
* @param parentEntry the entry to decorate
*/
protected MultiSetEntry(final Map.Entry parentEntry) {
@@ -195,11 +198,13 @@ public E getElement() {
* Mutable integer class for storing the data.
*/
protected static class MutableInteger {
+
/** The value of this mutable. */
protected int value;
/**
* Constructs a new instance.
+ *
* @param value the initial value
*/
MutableInteger(final int value) {
@@ -238,6 +243,7 @@ protected static class UniqueSetIterator extends AbstractIteratorDecorator
/**
* Constructs a new instance.
+ *
* @param iterator the iterator to decorate
* @param parent the parent multiset
*/
diff --git a/src/main/java/org/apache/commons/collections4/multiset/SynchronizedMultiSet.java b/src/main/java/org/apache/commons/collections4/multiset/SynchronizedMultiSet.java
index 426ad6438e..ccffd0946d 100644
--- a/src/main/java/org/apache/commons/collections4/multiset/SynchronizedMultiSet.java
+++ b/src/main/java/org/apache/commons/collections4/multiset/SynchronizedMultiSet.java
@@ -40,11 +40,13 @@ public class SynchronizedMultiSet extends SynchronizedCollection implement
* @param the type held in this Set.
*/
static class SynchronizedSet extends SynchronizedCollection implements Set {
+
/** Serialization version */
private static final long serialVersionUID = 20150629L;
/**
* Constructs a new instance.
+ *
* @param set the set to decorate
* @param lock the lock to use, shared with the multiset
*/
diff --git a/src/main/java/org/apache/commons/collections4/multiset/package-info.java b/src/main/java/org/apache/commons/collections4/multiset/package-info.java
index 58c1b4cd6c..5b8486f549 100644
--- a/src/main/java/org/apache/commons/collections4/multiset/package-info.java
+++ b/src/main/java/org/apache/commons/collections4/multiset/package-info.java
@@ -21,15 +21,17 @@
* A multiset stores an object and a count of the number of occurrences of the object.
*
* The following implementations are provided in the package:
+ *
*
- * - HashMultiSet - implementation that uses a HashMap to store the data
+ *
- HashMultiSet - implementation that uses a HashMap to store the data
*
*
* The following decorators are provided in the package:
+ *
*
- * - Predicated - ensures that only elements that are valid according to a predicate can be added
- *
- Synchronized - synchronizes method access for multithreaded environments
- *
- Unmodifiable - ensures the multiset cannot be altered
+ *
- Predicated - ensures that only elements that are valid according to a predicate can be added
+ * - Synchronized - synchronizes method access for multithreaded environments
+ * - Unmodifiable - ensures the multiset cannot be altered
*
*/
package org.apache.commons.collections4.multiset;
diff --git a/src/main/java/org/apache/commons/collections4/package-info.java b/src/main/java/org/apache/commons/collections4/package-info.java
index ef1e29105e..7e45d23606 100644
--- a/src/main/java/org/apache/commons/collections4/package-info.java
+++ b/src/main/java/org/apache/commons/collections4/package-info.java
@@ -21,7 +21,7 @@
* The following collection implementations are provided in the package:
*
*
- * - ArrayStack - a non synchronized Stack that follows the same API as {@code java.util Stack}
+ *
- ArrayStack - a non synchronized Stack that follows the same API as {@code java.util Stack}
*
*/
package org.apache.commons.collections4;
diff --git a/src/main/java/org/apache/commons/collections4/queue/package-info.java b/src/main/java/org/apache/commons/collections4/queue/package-info.java
index 5c8af6316a..a5ecac4779 100644
--- a/src/main/java/org/apache/commons/collections4/queue/package-info.java
+++ b/src/main/java/org/apache/commons/collections4/queue/package-info.java
@@ -19,15 +19,17 @@
* Implements the {@link java.util.Queue Queue} interface.
*
* The following implementations are provided in the package:
+ *
*
- * - CircularFifoQueue - implements a queue with a fixed size that discards oldest when full
+ *
- CircularFifoQueue - implements a queue with a fixed size that discards oldest when full
*
*
* The following decorators are provided in the package:
+ *
*
- * - Predicated - ensures that only elements that are valid according to a predicate can be added
- *
- Transformed - transforms elements added to the queue
- *
- Unmodifiable - ensures the collection cannot be altered
+ *
- Predicated - ensures that only elements that are valid according to a predicate can be added
+ * - Transformed - transforms elements added to the queue
+ * - Unmodifiable - ensures the collection cannot be altered
*
*/
package org.apache.commons.collections4.queue;
diff --git a/src/main/java/org/apache/commons/collections4/sequence/EditCommand.java b/src/main/java/org/apache/commons/collections4/sequence/EditCommand.java
index 5bdff115e5..8e3d92d8c8 100644
--- a/src/main/java/org/apache/commons/collections4/sequence/EditCommand.java
+++ b/src/main/java/org/apache/commons/collections4/sequence/EditCommand.java
@@ -17,7 +17,7 @@
package org.apache.commons.collections4.sequence;
/**
- * Abstract base class for all commands used to transform an objects sequence
+ * Abstract class for all commands used to transform an objects sequence
* into another one.
*
* When two objects sequences are compared through the
diff --git a/src/main/java/org/apache/commons/collections4/sequence/SequencesComparator.java b/src/main/java/org/apache/commons/collections4/sequence/SequencesComparator.java
index fd50612a20..a16ae01ad2 100644
--- a/src/main/java/org/apache/commons/collections4/sequence/SequencesComparator.java
+++ b/src/main/java/org/apache/commons/collections4/sequence/SequencesComparator.java
@@ -124,6 +124,7 @@ public int getStart() {
/** The equator used for testing object equality. */
private final Equator super T> equator;
+
/** Temporary variables. */
private final int[] vDown;
diff --git a/src/main/java/org/apache/commons/collections4/set/AbstractSetDecorator.java b/src/main/java/org/apache/commons/collections4/set/AbstractSetDecorator.java
index 7df2cd040d..9b0d010d86 100644
--- a/src/main/java/org/apache/commons/collections4/set/AbstractSetDecorator.java
+++ b/src/main/java/org/apache/commons/collections4/set/AbstractSetDecorator.java
@@ -37,6 +37,7 @@ public abstract class AbstractSetDecorator extends AbstractCollectionDecorato
/**
* Constructor only used in deserialization, do not use otherwise.
+ *
* @since 3.1
*/
protected AbstractSetDecorator() {
diff --git a/src/main/java/org/apache/commons/collections4/set/AbstractSortedSetDecorator.java b/src/main/java/org/apache/commons/collections4/set/AbstractSortedSetDecorator.java
index 4ac4831f1f..14d8d82778 100644
--- a/src/main/java/org/apache/commons/collections4/set/AbstractSortedSetDecorator.java
+++ b/src/main/java/org/apache/commons/collections4/set/AbstractSortedSetDecorator.java
@@ -38,6 +38,7 @@ public abstract class AbstractSortedSetDecorator
/**
* Constructor only used in deserialization, do not use otherwise.
+ *
* @since 3.1
*/
protected AbstractSortedSetDecorator() {
diff --git a/src/main/java/org/apache/commons/collections4/set/CompositeSet.java b/src/main/java/org/apache/commons/collections4/set/CompositeSet.java
index 6560153fc8..7c51e5eee0 100644
--- a/src/main/java/org/apache/commons/collections4/set/CompositeSet.java
+++ b/src/main/java/org/apache/commons/collections4/set/CompositeSet.java
@@ -289,6 +289,7 @@ public boolean containsAll(final Collection> coll) {
/**
* {@inheritDoc}
+ *
* @see java.util.Set#equals
*/
@Override
@@ -302,6 +303,7 @@ public boolean equals(final Object obj) {
/**
* Gets the set mutator to be used for this CompositeSet.
+ *
* @return the set mutator
*/
protected SetMutator getMutator() {
@@ -319,6 +321,7 @@ public List> getSets() {
/**
* {@inheritDoc}
+ *
* @see java.util.Set#hashCode
*/
@Override
diff --git a/src/main/java/org/apache/commons/collections4/set/package-info.java b/src/main/java/org/apache/commons/collections4/set/package-info.java
index 6448335055..25a8a31b30 100644
--- a/src/main/java/org/apache/commons/collections4/set/package-info.java
+++ b/src/main/java/org/apache/commons/collections4/set/package-info.java
@@ -23,18 +23,22 @@
* The implementations are in the form of direct implementations and decorators.
* A decorator wraps another implementation of the interface to add some
* specific additional functionality.
+ *
*
* The following implementations are provided in the package:
+ *
*
- * - CompositeSet - a set that combines multiple sets into one
+ *
- CompositeSet - a set that combines multiple sets into one
*
+ *
* The following decorators are provided in the package:
+ *
*
- * - Unmodifiable - ensures the collection cannot be altered
- *
- Predicated - ensures that only elements that are valid according to a predicate can be added
- *
- Transformed - transforms each element added
- *
- ListOrdered - ensures that insertion order is retained
- *
- MapBackedSet - a set formed by decorating a Map
+ *
- Unmodifiable - ensures the collection cannot be altered
+ * - Predicated - ensures that only elements that are valid according to a predicate can be added
+ * - Transformed - transforms each element added
+ * - ListOrdered - ensures that insertion order is retained
+ * - MapBackedSet - a set formed by decorating a Map
*
*/
package org.apache.commons.collections4.set;
diff --git a/src/main/java/org/apache/commons/collections4/splitmap/AbstractIterableGetMapDecorator.java b/src/main/java/org/apache/commons/collections4/splitmap/AbstractIterableGetMapDecorator.java
index 6b394e1fce..60bfe5df54 100644
--- a/src/main/java/org/apache/commons/collections4/splitmap/AbstractIterableGetMapDecorator.java
+++ b/src/main/java/org/apache/commons/collections4/splitmap/AbstractIterableGetMapDecorator.java
@@ -46,6 +46,7 @@ protected AbstractIterableGetMapDecorator() {
/**
* Create a new AbstractSplitMapDecorator.
+ *
* @param map the map to decorate, must not be null
* @throws NullPointerException if map is null
*/
@@ -107,6 +108,7 @@ public Set keySet() {
/**
* Gets a MapIterator over this Get.
+ *
* @return MapIterator<K, V>
*/
@Override
diff --git a/src/main/java/org/apache/commons/collections4/splitmap/TransformedSplitMap.java b/src/main/java/org/apache/commons/collections4/splitmap/TransformedSplitMap.java
index daea74af85..b1127a37e1 100644
--- a/src/main/java/org/apache/commons/collections4/splitmap/TransformedSplitMap.java
+++ b/src/main/java/org/apache/commons/collections4/splitmap/TransformedSplitMap.java
@@ -92,6 +92,7 @@ public static TransformedSplitMap transformingMap(final
final Transformer super U, ? extends V> valueTransformer) {
return new TransformedSplitMap<>(map, keyTransformer, valueTransformer);
}
+
/** The transformer to use for the key */
private final Transformer super J, ? extends K> keyTransformer;
diff --git a/src/main/java/org/apache/commons/collections4/splitmap/package-info.java b/src/main/java/org/apache/commons/collections4/splitmap/package-info.java
index e8ca8445fa..6b4bbc1be9 100644
--- a/src/main/java/org/apache/commons/collections4/splitmap/package-info.java
+++ b/src/main/java/org/apache/commons/collections4/splitmap/package-info.java
@@ -32,7 +32,7 @@
*
* The following decorators are provided:
*
- * - Transformed - transforms each element added
+ *
- Transformed - transforms each element added
*
*/
package org.apache.commons.collections4.splitmap;
diff --git a/src/main/java/org/apache/commons/collections4/trie/AbstractBitwiseTrie.java b/src/main/java/org/apache/commons/collections4/trie/AbstractBitwiseTrie.java
index b934f7c83f..d036313222 100644
--- a/src/main/java/org/apache/commons/collections4/trie/AbstractBitwiseTrie.java
+++ b/src/main/java/org/apache/commons/collections4/trie/AbstractBitwiseTrie.java
@@ -169,9 +169,9 @@ final K castKey(final Object key) {
}
/**
- * A utility method for calling {@link KeyAnalyzer#compare(Object, Object)}
+ * A null-safe utility method for calling {@link KeyAnalyzer#compare(Object, Object)}
*/
- final boolean compareKeys(final K key, final K other) {
+ final boolean keysAreEqual(final K key, final K other) {
if (key == null) {
return other == null;
}
@@ -184,6 +184,7 @@ final boolean compareKeys(final K key, final K other) {
/**
* Gets the {@link KeyAnalyzer} that constructed the {@link Trie}.
+ *
* @return the {@link KeyAnalyzer} used by this {@link Trie}
*/
protected KeyAnalyzer super K> getKeyAnalyzer() {
diff --git a/src/main/java/org/apache/commons/collections4/trie/AbstractPatriciaTrie.java b/src/main/java/org/apache/commons/collections4/trie/AbstractPatriciaTrie.java
index eead2e7233..472bbe17d4 100644
--- a/src/main/java/org/apache/commons/collections4/trie/AbstractPatriciaTrie.java
+++ b/src/main/java/org/apache/commons/collections4/trie/AbstractPatriciaTrie.java
@@ -342,6 +342,7 @@ public int size() {
return AbstractPatriciaTrie.this.size();
}
}
+
/**
* This is a key set view of the {@link org.apache.commons.collections4.Trie} as returned by {@link Map#keySet()}.
*/
@@ -384,6 +385,7 @@ public int size() {
return AbstractPatriciaTrie.this.size();
}
}
+
/**
* A prefix {@link RangeEntrySet} view of the {@link org.apache.commons.collections4.Trie}.
*/
@@ -1329,24 +1331,6 @@ TrieEntry addEntry(final TrieEntry entry, final int lengthInBits) {
* than or equal to the given key, or null if there is no such key.
*/
TrieEntry ceilingEntry(final K key) {
- // Basically:
- // Follow the steps of adding an entry, but instead...
- //
- // - If we ever encounter a situation where we found an equal
- // key, we return it immediately.
- //
- // - If we hit an empty root, return the first iterable item.
- //
- // - If we have to add a new item, we temporarily add it,
- // find the successor to it, then remove the added item.
- //
- // These steps ensure that the returned value is either the
- // entry for the key itself, or the first entry directly after
- // the key.
-
- // TODO: Cleanup so that we don't actually have to add/remove from the
- // tree. (We do it here because there are other well-defined
- // functions to perform the search.)
final int lengthInBits = lengthInBits(key);
if (lengthInBits == 0) {
@@ -1357,19 +1341,31 @@ TrieEntry ceilingEntry(final K key) {
}
final TrieEntry found = getNearestEntryForKey(key, lengthInBits);
- if (compareKeys(key, found.key)) {
+ if (keysAreEqual(key, found.key)) {
return found;
}
final int bitIndex = bitIndex(key, found.key);
if (KeyAnalyzer.isValidBitIndex(bitIndex)) {
- final TrieEntry added = new TrieEntry<>(key, null, bitIndex);
- addEntry(added, lengthInBits);
- incrementSize(); // must increment because remove will decrement
- final TrieEntry ceil = nextEntry(added);
- removeEntry(added);
- modCount -= 2; // we didn't really modify it.
- return ceil;
+ if (!isBitSet(key, bitIndex, lengthInBits)) {
+ // search key < found.key
+ // found is a ceiling candidate, walk backward to find the smallest entry still >= key
+ TrieEntry ceiling = found;
+ TrieEntry prev = previousEntry(found);
+ while (prev != null && !prev.isEmpty() && getKeyAnalyzer().compare(key, prev.key) <= 0) {
+ ceiling = prev;
+ prev = previousEntry(prev);
+ }
+ return ceiling;
+ } else {
+ // search key > found.key
+ // walk forward to find the first entry.key > key
+ TrieEntry next = nextEntry(found);
+ while (next != null && getKeyAnalyzer().compare(key, next.key) > 0) {
+ next = nextEntry(next);
+ }
+ return next;
+ }
}
if (KeyAnalyzer.isNullBitKey(bitIndex)) {
if (!root.isEmpty()) {
@@ -1414,7 +1410,7 @@ public boolean containsKey(final Object k) {
final K key = castKey(k);
final int lengthInBits = lengthInBits(key);
final TrieEntry entry = getNearestEntryForKey(key, lengthInBits);
- return !entry.isEmpty() && compareKeys(key, entry.key);
+ return !entry.isEmpty() && keysAreEqual(key, entry.key);
}
/**
@@ -1461,9 +1457,6 @@ public K firstKey() {
* less than or equal to the given key, or null if there is no such key.
*/
TrieEntry floorEntry(final K key) {
- // TODO: Cleanup so that we don't actually have to add/remove from the
- // tree. (We do it here because there are other well-defined
- // functions to perform the search.)
final int lengthInBits = lengthInBits(key);
if (lengthInBits == 0) {
@@ -1474,19 +1467,30 @@ TrieEntry floorEntry(final K key) {
}
final TrieEntry found = getNearestEntryForKey(key, lengthInBits);
- if (compareKeys(key, found.key)) {
+ if (keysAreEqual(key, found.key)) {
return found;
}
final int bitIndex = bitIndex(key, found.key);
if (KeyAnalyzer.isValidBitIndex(bitIndex)) {
- final TrieEntry added = new TrieEntry<>(key, null, bitIndex);
- addEntry(added, lengthInBits);
- incrementSize(); // must increment because remove will decrement
- final TrieEntry floor = previousEntry(added);
- removeEntry(added);
- modCount -= 2; // we didn't really modify it.
- return floor;
+ if (isBitSet(key, bitIndex, lengthInBits)) {
+ TrieEntry floor = found;
+ TrieEntry next = nextEntry(found);
+ while (next != null && getKeyAnalyzer().compare(key, next.key) >= 0) {
+ floor = next;
+ next = nextEntry(next);
+ }
+ return floor;
+ } else {
+ TrieEntry prev = previousEntry(found);
+ while (prev != null && !prev.isEmpty() && getKeyAnalyzer().compare(key, prev.key) < 0) {
+ prev = previousEntry(prev);
+ }
+ if (prev == null || prev.isEmpty()) {
+ return null;
+ }
+ return prev;
+ }
}
if (KeyAnalyzer.isNullBitKey(bitIndex)) {
if (!root.isEmpty()) {
@@ -1559,7 +1563,7 @@ TrieEntry getEntry(final Object k) {
final int lengthInBits = lengthInBits(key);
final TrieEntry entry = getNearestEntryForKey(key, lengthInBits);
- return !entry.isEmpty() && compareKeys(key, entry.key) ? entry : null;
+ return !entry.isEmpty() && keysAreEqual(key, entry.key) ? entry : null;
}
/**
@@ -1630,9 +1634,6 @@ public SortedMap headMap(final K toKey) {
* or null if no such entry exists.
*/
TrieEntry higherEntry(final K key) {
- // TODO: Cleanup so that we don't actually have to add/remove from the
- // tree. (We do it here because there are other well-defined
- // functions to perform the search.)
final int lengthInBits = lengthInBits(key);
if (lengthInBits == 0) {
@@ -1649,19 +1650,27 @@ TrieEntry higherEntry(final K key) {
}
final TrieEntry found = getNearestEntryForKey(key, lengthInBits);
- if (compareKeys(key, found.key)) {
+ if (keysAreEqual(key, found.key)) {
return nextEntry(found);
}
final int bitIndex = bitIndex(key, found.key);
if (KeyAnalyzer.isValidBitIndex(bitIndex)) {
- final TrieEntry added = new TrieEntry<>(key, null, bitIndex);
- addEntry(added, lengthInBits);
- incrementSize(); // must increment because remove will decrement
- final TrieEntry ceil = nextEntry(added);
- removeEntry(added);
- modCount -= 2; // we didn't really modify it.
- return ceil;
+ if (!isBitSet(key, bitIndex, lengthInBits)) {
+ TrieEntry ceiling = found;
+ TrieEntry prev = previousEntry(found);
+ while (prev != null && !prev.isEmpty() && getKeyAnalyzer().compare(key, prev.key) <= 0) {
+ ceiling = prev;
+ prev = previousEntry(prev);
+ }
+ return ceiling;
+ } else {
+ TrieEntry next = nextEntry(found);
+ while (next != null && getKeyAnalyzer().compare(key, next.key) > 0) {
+ next = nextEntry(next);
+ }
+ return next;
+ }
}
if (KeyAnalyzer.isNullBitKey(bitIndex)) {
if (!root.isEmpty()) {
@@ -1727,23 +1736,6 @@ public K lastKey() {
* strictly less than the given key, or null if there is no such key.
*/
TrieEntry lowerEntry(final K key) {
- // Basically:
- // Follow the steps of adding an entry, but instead...
- //
- // - If we ever encounter a situation where we found an equal
- // key, we return it's previousEntry immediately.
- //
- // - If we hit root (empty or not), return null.
- //
- // - If we have to add a new item, we temporarily add it,
- // find the previousEntry to it, then remove the added item.
- //
- // These steps ensure that the returned value is always just before
- // the key or null (if there was nothing before it).
-
- // TODO: Cleanup so that we don't actually have to add/remove from the
- // tree. (We do it here because there are other well-defined
- // functions to perform the search.)
final int lengthInBits = lengthInBits(key);
if (lengthInBits == 0) {
@@ -1751,19 +1743,30 @@ TrieEntry lowerEntry(final K key) {
}
final TrieEntry found = getNearestEntryForKey(key, lengthInBits);
- if (compareKeys(key, found.key)) {
+ if (keysAreEqual(key, found.key)) {
return previousEntry(found);
}
final int bitIndex = bitIndex(key, found.key);
if (KeyAnalyzer.isValidBitIndex(bitIndex)) {
- final TrieEntry added = new TrieEntry<>(key, null, bitIndex);
- addEntry(added, lengthInBits);
- incrementSize(); // must increment because remove will decrement
- final TrieEntry prior = previousEntry(added);
- removeEntry(added);
- modCount -= 2; // we didn't really modify it.
- return prior;
+ if (isBitSet(key, bitIndex, lengthInBits)) {
+ TrieEntry floor = found;
+ TrieEntry next = nextEntry(found);
+ while (next != null && getKeyAnalyzer().compare(key, next.key) >= 0) {
+ floor = next;
+ next = nextEntry(next);
+ }
+ return floor;
+ } else {
+ TrieEntry prev = previousEntry(found);
+ while (prev != null && !prev.isEmpty() && getKeyAnalyzer().compare(key, prev.key) < 0) {
+ prev = previousEntry(prev);
+ }
+ if (prev == null || prev.isEmpty()) {
+ return null;
+ }
+ return prev;
+ }
}
if (KeyAnalyzer.isNullBitKey(bitIndex)) {
return null;
@@ -2026,7 +2029,7 @@ public V put(final K key, final V value) {
}
final TrieEntry found = getNearestEntryForKey(key, lengthInBits);
- if (compareKeys(key, found.key)) {
+ if (keysAreEqual(key, found.key)) {
if (found.isEmpty()) { // <- must be the root
incrementSize();
} else {
@@ -2102,7 +2105,7 @@ public V remove(final Object k) {
TrieEntry path = root;
while (true) {
if (current.bitIndex <= path.bitIndex) {
- if (!current.isEmpty() && compareKeys(key, current.key)) {
+ if (!current.isEmpty() && keysAreEqual(key, current.key)) {
return removeEntry(current);
}
return null;
@@ -2259,9 +2262,9 @@ private void removeInternalEntry(final TrieEntry h) {
* For example, given the keys:
*
*
- * - D = 1000100
- *
- H = 1001000
- *
- L = 1001100
+ *
- D = 1000100
+ * - H = 1001000
+ * - L = 1001100
*
*
* If the {@link org.apache.commons.collections4.Trie} contained 'H' and 'L', a lookup of 'D' would
@@ -2288,9 +2291,9 @@ public Map.Entry select(final K key) {
* For example, given the keys:
*
*
- * - D = 1000100
- *
- H = 1001000
- *
- L = 1001100
+ *
- D = 1000100
+ * - H = 1001000
+ * - L = 1001100
*
*
* If the {@link org.apache.commons.collections4.Trie} contained 'H' and 'L', a lookup of 'D' would
@@ -2340,9 +2343,9 @@ private boolean selectR(final TrieEntry h, final int bitIndex,
* For example, given the keys:
*
*
- * - D = 1000100
- *
- H = 1001000
- *
- L = 1001100
+ *
- D = 1000100
+ * - H = 1001000
+ * - L = 1001100
*
*
* If the {@link org.apache.commons.collections4.Trie} contained 'H' and 'L', a lookup of 'D' would
diff --git a/src/main/java/org/apache/commons/collections4/trie/analyzer/StringKeyAnalyzer.java b/src/main/java/org/apache/commons/collections4/trie/analyzer/StringKeyAnalyzer.java
index d3d76a2589..6b0aaa6dfb 100644
--- a/src/main/java/org/apache/commons/collections4/trie/analyzer/StringKeyAnalyzer.java
+++ b/src/main/java/org/apache/commons/collections4/trie/analyzer/StringKeyAnalyzer.java
@@ -23,6 +23,7 @@
*
* This class is stateless.
*
+ *
* @since 4.0
*/
public class StringKeyAnalyzer extends KeyAnalyzer {
diff --git a/src/main/java/org/apache/commons/collections4/trie/package-info.java b/src/main/java/org/apache/commons/collections4/trie/package-info.java
index 293c3074a8..04d203d0f0 100644
--- a/src/main/java/org/apache/commons/collections4/trie/package-info.java
+++ b/src/main/java/org/apache/commons/collections4/trie/package-info.java
@@ -22,15 +22,18 @@
* The implementations are in the form of direct implementations and decorators.
* A decorator wraps another implementation of the interface to add some
* specific additional functionality.
+ *
*
* The following implementations are provided in the package:
+ *
*
- * - PatriciaTrie - an implementation of a PATRICIA trie
+ *
- PatriciaTrie - an implementation of a PATRICIA trie
*
*
* The following decorators are provided:
+ *
*
- * - Unmodifiable - ensures the collection cannot be altered
+ *
- Unmodifiable - ensures the collection cannot be altered
*
*/
package org.apache.commons.collections4.trie;
diff --git a/src/site/xdoc/building.xml b/src/site/xdoc/building.xml
index 29a33f8a6c..504ffd3041 100644
--- a/src/site/xdoc/building.xml
+++ b/src/site/xdoc/building.xml
@@ -17,7 +17,7 @@
-->
+ xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 https://maven.apache.org/xsd/xdoc-2.0.xsd">
Building
Apache Commons Team
diff --git a/src/site/xdoc/compatibility.xml b/src/site/xdoc/compatibility.xml
index 7663e6a1eb..65d5728a0b 100644
--- a/src/site/xdoc/compatibility.xml
+++ b/src/site/xdoc/compatibility.xml
@@ -17,7 +17,7 @@
-->
+ xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 https://maven.apache.org/xsd/xdoc-2.0.xsd">
Compatibility
Apache Commons Team
diff --git a/src/site/xdoc/download_collections.xml b/src/site/xdoc/download_collections.xml
index c04d1ce314..789da0245e 100644
--- a/src/site/xdoc/download_collections.xml
+++ b/src/site/xdoc/download_collections.xml
@@ -58,7 +58,7 @@ limitations under the License.
-->
+ xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 https://maven.apache.org/xsd/xdoc-2.0.xsd">
Download Apache Commons Collections
Apache Commons Team
diff --git a/src/site/xdoc/history.xml b/src/site/xdoc/history.xml
index 5cdffe4bd8..9dbca3f23c 100644
--- a/src/site/xdoc/history.xml
+++ b/src/site/xdoc/history.xml
@@ -17,7 +17,7 @@
-->
+ xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 https://maven.apache.org/xsd/xdoc-2.0.xsd">
History
Apache Commons Team
diff --git a/src/site/xdoc/index.xml b/src/site/xdoc/index.xml
index 9b2609847c..aa7af2ae4e 100644
--- a/src/site/xdoc/index.xml
+++ b/src/site/xdoc/index.xml
@@ -17,7 +17,7 @@
-->
+ xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 https://maven.apache.org/xsd/xdoc-2.0.xsd">
Home
Apache Commons Team
diff --git a/src/site/xdoc/issue-tracking.xml b/src/site/xdoc/issue-tracking.xml
index 6f617d9a2c..f296f577a0 100644
--- a/src/site/xdoc/issue-tracking.xml
+++ b/src/site/xdoc/issue-tracking.xml
@@ -43,7 +43,7 @@ limitations under the License.
-->
+ xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 https://maven.apache.org/xsd/xdoc-2.0.xsd">
Apache Commons Collections Issue tracking
Apache Commons Team
diff --git a/src/site/xdoc/mail-lists.xml b/src/site/xdoc/mail-lists.xml
index 58d28d1246..e59bf52bb5 100644
--- a/src/site/xdoc/mail-lists.xml
+++ b/src/site/xdoc/mail-lists.xml
@@ -41,7 +41,7 @@ limitations under the License.
-->
+ xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 https://maven.apache.org/xsd/xdoc-2.0.xsd">
Apache Commons Collections Mailing Lists
Apache Commons Team
diff --git a/src/site/xdoc/pick.xml b/src/site/xdoc/pick.xml
index 392fad52b0..408f51dc7f 100644
--- a/src/site/xdoc/pick.xml
+++ b/src/site/xdoc/pick.xml
@@ -17,7 +17,7 @@
-->
+ xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 https://maven.apache.org/xsd/xdoc-2.0.xsd">
Choosing a collection
Apache Commons Team
diff --git a/src/site/xdoc/proposal.xml b/src/site/xdoc/proposal.xml
index f0a9481925..e936cfaf2e 100644
--- a/src/site/xdoc/proposal.xml
+++ b/src/site/xdoc/proposal.xml
@@ -17,7 +17,7 @@
-->
+ xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 https://maven.apache.org/xsd/xdoc-2.0.xsd">
Proposal
diff --git a/src/site/xdoc/release_3_2.xml b/src/site/xdoc/release_3_2.xml
index f729134ba9..e26d065ef0 100644
--- a/src/site/xdoc/release_3_2.xml
+++ b/src/site/xdoc/release_3_2.xml
@@ -17,7 +17,7 @@
-->
+ xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 https://maven.apache.org/xsd/xdoc-2.0.xsd">
Release notes for version 3.2
Apache Commons Team
diff --git a/src/site/xdoc/release_3_2_1.xml b/src/site/xdoc/release_3_2_1.xml
index 329d61d03e..1d486c3723 100644
--- a/src/site/xdoc/release_3_2_1.xml
+++ b/src/site/xdoc/release_3_2_1.xml
@@ -17,7 +17,7 @@
-->
+ xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 https://maven.apache.org/xsd/xdoc-2.0.xsd">
Release notes for version 3.2.1
Apache Commons Team
diff --git a/src/site/xdoc/release_3_2_2.xml b/src/site/xdoc/release_3_2_2.xml
index a4c9847c04..90ac6aae95 100644
--- a/src/site/xdoc/release_3_2_2.xml
+++ b/src/site/xdoc/release_3_2_2.xml
@@ -17,7 +17,7 @@
-->
+ xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 https://maven.apache.org/xsd/xdoc-2.0.xsd">
Release notes for version 3.2.2
Apache Commons Team
diff --git a/src/site/xdoc/release_4_0.xml b/src/site/xdoc/release_4_0.xml
index 122d5a2334..f101757346 100644
--- a/src/site/xdoc/release_4_0.xml
+++ b/src/site/xdoc/release_4_0.xml
@@ -17,7 +17,7 @@
-->
+ xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 https://maven.apache.org/xsd/xdoc-2.0.xsd">
Release notes for version 4.0
Apache Commons Team
diff --git a/src/site/xdoc/release_4_1.xml b/src/site/xdoc/release_4_1.xml
index ab372a377f..d5628cec0e 100644
--- a/src/site/xdoc/release_4_1.xml
+++ b/src/site/xdoc/release_4_1.xml
@@ -17,7 +17,7 @@
-->
+ xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 https://maven.apache.org/xsd/xdoc-2.0.xsd">
Release notes for version 4.1
Apache Commons Team
diff --git a/src/site/xdoc/release_4_2.xml b/src/site/xdoc/release_4_2.xml
index 89b1a4927a..757d3b2a55 100644
--- a/src/site/xdoc/release_4_2.xml
+++ b/src/site/xdoc/release_4_2.xml
@@ -17,7 +17,7 @@
-->
+ xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 https://maven.apache.org/xsd/xdoc-2.0.xsd">
Release notes for v4.2
Apache Commons Team
diff --git a/src/site/xdoc/release_4_3.xml b/src/site/xdoc/release_4_3.xml
index db6ac4433c..0d77a48097 100644
--- a/src/site/xdoc/release_4_3.xml
+++ b/src/site/xdoc/release_4_3.xml
@@ -17,7 +17,7 @@
-->
+ xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 https://maven.apache.org/xsd/xdoc-2.0.xsd">
Release notes for v4.3
Apache Commons Team
diff --git a/src/site/xdoc/release_4_4.xml b/src/site/xdoc/release_4_4.xml
index d1f668f889..de24fbdc44 100644
--- a/src/site/xdoc/release_4_4.xml
+++ b/src/site/xdoc/release_4_4.xml
@@ -17,7 +17,7 @@
-->
+ xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 https://maven.apache.org/xsd/xdoc-2.0.xsd">
Release notes for v4.4
Apache Commons Team
diff --git a/src/site/xdoc/security.xml b/src/site/xdoc/security.xml
index 01b6c83c50..2764a363bd 100644
--- a/src/site/xdoc/security.xml
+++ b/src/site/xdoc/security.xml
@@ -110,5 +110,10 @@
Please report any errors or omissions to the dev mailing list.
-
+
+
diff --git a/src/site/xdoc/userguide.xml b/src/site/xdoc/userguide.xml
index 28cece2c26..07a96019bc 100644
--- a/src/site/xdoc/userguide.xml
+++ b/src/site/xdoc/userguide.xml
@@ -17,7 +17,7 @@
-->
+ xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 https://maven.apache.org/xsd/xdoc-2.0.xsd">
User guide
Apache Commons Team
diff --git a/src/test/java/org/apache/commons/collections4/AbstractObjectTest.java b/src/test/java/org/apache/commons/collections4/AbstractObjectTest.java
index db2eaa5cbc..4a31e6e848 100644
--- a/src/test/java/org/apache/commons/collections4/AbstractObjectTest.java
+++ b/src/test/java/org/apache/commons/collections4/AbstractObjectTest.java
@@ -74,7 +74,6 @@ protected String getCanonicalFullCollectionName(final Object object) {
return retval.toString();
}
- // protected implementation
/**
* Gets the version of Collections that this object tries to
* maintain serialization compatibility with. Defaults to 4, due to
diff --git a/src/test/java/org/apache/commons/collections4/FactoryUtilsTest.java b/src/test/java/org/apache/commons/collections4/FactoryUtilsTest.java
index c35b5b785f..90f020bffd 100644
--- a/src/test/java/org/apache/commons/collections4/FactoryUtilsTest.java
+++ b/src/test/java/org/apache/commons/collections4/FactoryUtilsTest.java
@@ -65,6 +65,7 @@ public int hashCode() { // please Findbugs
}
public static class Mock2 implements Serializable {
+
/**
* Generated serial version ID.
*/
diff --git a/src/test/java/org/apache/commons/collections4/MultiMapUtilsTest.java b/src/test/java/org/apache/commons/collections4/MultiMapUtilsTest.java
index 14f177f2b4..7ff98ba078 100644
--- a/src/test/java/org/apache/commons/collections4/MultiMapUtilsTest.java
+++ b/src/test/java/org/apache/commons/collections4/MultiMapUtilsTest.java
@@ -29,6 +29,8 @@
import java.util.Set;
import org.apache.commons.collections4.multimap.ArrayListValuedHashMap;
+import org.apache.commons.collections4.multimap.HashSetValuedHashMap;
+import org.apache.commons.collections4.multimap.LinkedHashSetValuedLinkedHashMap;
import org.junit.jupiter.api.Test;
/**
@@ -116,6 +118,30 @@ void testGetValuesAsSet() {
assertEquals(new HashSet<>(Arrays.asList(values)), set);
}
+ @Test
+ void testInvert() {
+ final HashSetValuedHashMap usages = new HashSetValuedHashMap<>();
+
+ final LinkedHashSetValuedLinkedHashMap deps = new LinkedHashSetValuedLinkedHashMap<>();
+ deps.put("commons-configuration2", "commons-logging");
+ deps.put("commons-configuration2", "commons-lang3");
+ deps.put("commons-configuration2", "commons-text");
+ deps.put("commons-beanutils", "commons-collections");
+ deps.put("commons-beanutils", "commons-logging");
+ MultiMapUtils.invert(deps, usages);
+ final Set loggingUsagesCompile = usages.get("commons-logging");
+ assertEquals("[commons-configuration2, commons-beanutils]", loggingUsagesCompile.toString());
+ final Set codecUsagesCompile = usages.get("commons-codec");
+ assertEquals("[]", codecUsagesCompile.toString());
+
+ final LinkedHashSetValuedLinkedHashMap optionalDeps = new LinkedHashSetValuedLinkedHashMap<>();
+ optionalDeps.put("commons-configuration2", "commons-codec");
+ optionalDeps.put("commons-collections", "commons-codec");
+ MultiMapUtils.invert(optionalDeps, usages);
+ final Set codecUsagesAll = usages.get("commons-codec");
+ assertEquals("[commons-collections, commons-configuration2]", codecUsagesAll.toString());
+ }
+
@Test
void testIsEmptyWithEmptyMap() {
assertTrue(MultiMapUtils.isEmpty(new ArrayListValuedHashMap<>()));
diff --git a/src/test/java/org/apache/commons/collections4/bloomfilter/AbstractCellExtractorTest.java b/src/test/java/org/apache/commons/collections4/bloomfilter/AbstractCellExtractorTest.java
index 2753bd4d68..0e1a95f19a 100644
--- a/src/test/java/org/apache/commons/collections4/bloomfilter/AbstractCellExtractorTest.java
+++ b/src/test/java/org/apache/commons/collections4/bloomfilter/AbstractCellExtractorTest.java
@@ -34,6 +34,7 @@ public abstract class AbstractCellExtractorTest extends AbstractIndexExtractorTe
* A testing CellConsumer that always returns true.
*/
private static final CellPredicate TRUE_CONSUMER = (i, j) -> true;
+
/**
* A testing CellConsumer that always returns false.
*/
diff --git a/src/test/java/org/apache/commons/collections4/bloomfilter/AbstractIndexExtractorTest.java b/src/test/java/org/apache/commons/collections4/bloomfilter/AbstractIndexExtractorTest.java
index fefc54998c..163743c842 100644
--- a/src/test/java/org/apache/commons/collections4/bloomfilter/AbstractIndexExtractorTest.java
+++ b/src/test/java/org/apache/commons/collections4/bloomfilter/AbstractIndexExtractorTest.java
@@ -66,6 +66,7 @@ int[] toArray() {
private static final IntPredicate TRUE_PREDICATE = i -> true;
private static final IntPredicate FALSE_PREDICATE = i -> false;
+
/** Flag to indicate the indices are ordered, for example from {@link IndexExtractor#processIndices(IntPredicate)}. */
protected static final int ORDERED = 0x1;
diff --git a/src/test/java/org/apache/commons/collections4/bloomfilter/LayeredBloomFilterTest.java b/src/test/java/org/apache/commons/collections4/bloomfilter/LayeredBloomFilterTest.java
index de5ba276cd..a4eb2a8553 100644
--- a/src/test/java/org/apache/commons/collections4/bloomfilter/LayeredBloomFilterTest.java
+++ b/src/test/java/org/apache/commons/collections4/bloomfilter/LayeredBloomFilterTest.java
@@ -260,6 +260,7 @@ void testCleanup() {
f = underTest.get(0);
assertEquals(3, f.sequence); // it is a new one.
}
+
/**
* Tests that the estimated union calculations are correct.
*/
diff --git a/src/test/java/org/apache/commons/collections4/bloomfilter/TestingHashers.java b/src/test/java/org/apache/commons/collections4/bloomfilter/TestingHashers.java
index 161e2d0ff0..90dce57897 100644
--- a/src/test/java/org/apache/commons/collections4/bloomfilter/TestingHashers.java
+++ b/src/test/java/org/apache/commons/collections4/bloomfilter/TestingHashers.java
@@ -22,6 +22,7 @@
* A collection of methods and statics that represent standard hashers in testing.
*/
public class TestingHashers {
+
/**
* Hasher that increments from 1.
*/
diff --git a/src/test/java/org/apache/commons/collections4/collection/AbstractCollectionTest.java b/src/test/java/org/apache/commons/collections4/collection/AbstractCollectionTest.java
index bec79c3e09..1645d72c13 100644
--- a/src/test/java/org/apache/commons/collections4/collection/AbstractCollectionTest.java
+++ b/src/test/java/org/apache/commons/collections4/collection/AbstractCollectionTest.java
@@ -261,45 +261,45 @@ private static void assertUnorderedArrayEquals(final Object[] a1, final Object[]
}
/**
- * A collection instance that will be used for testing.
+ * A collection instance that will be used for testing.
*/
private Collection collection;
/**
- * Confirmed collection. This is an instance of a collection that is
- * confirmed to conform exactly to the java.util.Collection contract.
- * Modification operations are tested by performing a mod on your
- * collection, performing the exact same mod on an equivalent confirmed
- * collection, and then calling verify() to make sure your collection
- * still matches the confirmed collection.
+ * Confirmed collection. This is an instance of a collection that is
+ * confirmed to conform exactly to the java.util.Collection contract.
+ * Modification operations are tested by performing a mod on your
+ * collection, performing the exact same mod on an equivalent confirmed
+ * collection, and then calling verify() to make sure your collection
+ * still matches the confirmed collection.
*/
private Collection confirmed;
/**
- * Specifies whether equal elements in the collection are, in fact,
- * distinguishable with information not readily available.
- *
- * If a particular value is to be removed from the collection, then there is
- * one and only one value that can be removed, even if there are other
- * elements which are equal to it.
- *
- *
- * In most collection cases, elements are not distinguishable (equal is
- * equal), thus this method defaults to return false. In some cases,
- * however, they are. For example, the collection returned from the map's
- * values() collection view are backed by the map, so while there may be
- * two values that are equal, their associated keys are not. Since the
- * keys are distinguishable, the values are.
- *
- *
- * This flag is used to skip some verifications for iterator.remove()
- * where it is impossible to perform an equivalent modification on the
- * confirmed collection because it is not possible to determine which
- * value in the confirmed collection to actually remove. Tests that
- * override the default (i.e. where equal elements are distinguishable),
- * should provide additional tests on iterator.remove() to make sure the
- * proper elements are removed when remove() is called on the iterator.
- *
+ * Specifies whether equal elements in the collection are, in fact,
+ * distinguishable with information not readily available.
+ *
+ * If a particular value is to be removed from the collection, then there is
+ * one and only one value that can be removed, even if there are other
+ * elements which are equal to it.
+ *
+ *
+ * In most collection cases, elements are not distinguishable (equal is
+ * equal), thus this method defaults to return false. In some cases,
+ * however, they are. For example, the collection returned from the map's
+ * values() collection view are backed by the map, so while there may be
+ * two values that are equal, their associated keys are not. Since the
+ * keys are distinguishable, the values are.
+ *
+ *
+ * This flag is used to skip some verifications for iterator.remove()
+ * where it is impossible to perform an equivalent modification on the
+ * confirmed collection because it is not possible to determine which
+ * value in the confirmed collection to actually remove. Tests that
+ * override the default (i.e. where equal elements are distinguishable),
+ * should provide additional tests on iterator.remove() to make sure the
+ * proper elements are removed when remove() is called on the iterator.
+ *
*/
public boolean areEqualElementsDistinguishable() {
return false;
@@ -323,18 +323,18 @@ public Collection getConfirmed() {
}
/**
- * Returns an array of objects that are contained in a collection
- * produced by {@link #makeFullCollection()}.
- *
- * Every element in the returned array must be an element in a full collection.
- *
- *
- * The default implementation returns a heterogeneous array of
- * objects with some duplicates. null is added if allowed.
- * Override if you require specific testing elements. Note that if you
- * override {@link #makeFullCollection()}, you must override
- * this method to reflect the contents of a full collection.
- *
+ * Returns an array of objects that are contained in a collection
+ * produced by {@link #makeFullCollection()}.
+ *
+ * Every element in the returned array must be an element in a full collection.
+ *
+ *
+ * The default implementation returns a heterogeneous array of
+ * objects with some duplicates. null is added if allowed.
+ * Override if you require specific testing elements. Note that if you
+ * override {@link #makeFullCollection()}, you must override
+ * this method to reflect the contents of a full collection.
+ *
*/
@SuppressWarnings("unchecked")
public E[] getFullElements() {
@@ -347,12 +347,12 @@ public E[] getFullElements() {
}
/**
- * Returns a list of elements suitable for return by
- * {@link #getFullElements()}. The array returned by this method
- * does not include null, but does include a variety of objects
- * of different types. Override getFullElements to return
- * the results of this method if your collection does not support
- * the null element.
+ * Returns a list of elements suitable for return by
+ * {@link #getFullElements()}. The array returned by this method
+ * does not include null, but does include a variety of objects
+ * of different types. Override getFullElements to return
+ * the results of this method if your collection does not support
+ * the null element.
*/
@SuppressWarnings("unchecked")
public E[] getFullNonNullElements() {
@@ -379,10 +379,10 @@ public E[] getFullNonNullElements() {
}
/**
- * Returns a list of string elements suitable for return by
- * {@link #getFullElements()}. Override getFullElements to return
- * the results of this method if your collection does not support
- * heterogeneous elements or the null element.
+ * Returns a list of string elements suitable for return by
+ * {@link #getFullElements()}. Override getFullElements to return
+ * the results of this method if your collection does not support
+ * heterogeneous elements or the null element.
*/
public Object[] getFullNonNullStringElements() {
return new Object[] {
@@ -404,22 +404,22 @@ protected int getIterationBehaviour() {
}
/**
- * Returns an array of elements that are not contained in a
- * full collection. Every element in the returned array must
- * not exist in a collection returned by {@link #makeFullCollection()}.
- * The default implementation returns a heterogeneous array of elements
- * without null. Note that some of the tests add these elements
- * to an empty or full collection, so if your collection restricts
- * certain kinds of elements, you should override this method.
+ * Returns an array of elements that are not contained in a
+ * full collection. Every element in the returned array must
+ * not exist in a collection returned by {@link #makeFullCollection()}.
+ * The default implementation returns a heterogeneous array of elements
+ * without null. Note that some of the tests add these elements
+ * to an empty or full collection, so if your collection restricts
+ * certain kinds of elements, you should override this method.
*/
public E[] getOtherElements() {
return getOtherNonNullElements();
}
/**
- * Returns the default list of objects returned by
- * {@link #getOtherElements()}. Includes many objects
- * of different types.
+ * Returns the default list of objects returned by
+ * {@link #getOtherElements()}. Includes many objects
+ * of different types.
*/
@SuppressWarnings("unchecked")
public E[] getOtherNonNullElements() {
@@ -437,10 +437,10 @@ public E[] getOtherNonNullElements() {
}
/**
- * Returns a list of string elements suitable for return by
- * {@link #getOtherElements()}. Override getOtherElements to return
- * the results of this method if your collection does not support
- * heterogeneous elements or the null element.
+ * Returns a list of string elements suitable for return by
+ * {@link #getOtherElements()}. Override getOtherElements to return
+ * the results of this method if your collection does not support
+ * heterogeneous elements or the null element.
*/
public Object[] getOtherNonNullStringElements() {
return new Object[] {
@@ -450,14 +450,14 @@ public Object[] getOtherNonNullStringElements() {
}
/**
- * Returns true if the collections produced by
- * {@link #makeObject()} and {@link #makeFullCollection()}
- * support the {@code add} and {@code addAll}
- * operations.
- *
- * Default implementation returns true. Override if your collection
- * class does not support add or addAll.
- *
+ * Returns true if the collections produced by
+ * {@link #makeObject()} and {@link #makeFullCollection()}
+ * support the {@code add} and {@code addAll}
+ * operations.
+ *
+ * Default implementation returns true. Override if your collection
+ * class does not support add or addAll.
+ *
*/
public boolean isAddSupported() {
return true;
@@ -489,44 +489,44 @@ public boolean isNullSupported() {
}
/**
- * Returns true if the collections produced by
- * {@link #makeObject()} and {@link #makeFullCollection()}
- * support the {@code remove}, {@code removeAll},
- * {@code retainAll}, {@code clear} and
- * {@code iterator().remove()} methods.
- * Default implementation returns true. Override if your collection
- * class does not support removal operations.
+ * Returns true if the collections produced by
+ * {@link #makeObject()} and {@link #makeFullCollection()}
+ * support the {@code remove}, {@code removeAll},
+ * {@code retainAll}, {@code clear} and
+ * {@code iterator().remove()} methods.
+ * Default implementation returns true. Override if your collection
+ * class does not support removal operations.
*/
public boolean isRemoveSupported() {
return true;
}
/**
- * Returns a confirmed empty collection.
- * For instance, an {@link java.util.ArrayList} for lists or a
- * {@link java.util.HashSet} for sets.
+ * Returns a confirmed empty collection.
+ * For instance, an {@link java.util.ArrayList} for lists or a
+ * {@link java.util.HashSet} for sets.
*
- * @return a confirmed empty collection
+ * @return a confirmed empty collection
*/
public abstract Collection makeConfirmedCollection();
/**
- * Returns a confirmed full collection.
- * For instance, an {@link java.util.ArrayList} for lists or a
- * {@link java.util.HashSet} for sets. The returned collection
- * should contain the elements returned by {@link #getFullElements()}.
+ * Returns a confirmed full collection.
+ * For instance, an {@link java.util.ArrayList} for lists or a
+ * {@link java.util.HashSet} for sets. The returned collection
+ * should contain the elements returned by {@link #getFullElements()}.
*
- * @return a confirmed full collection
+ * @return a confirmed full collection
*/
public abstract Collection makeConfirmedFullCollection();
/**
- * Returns a full collection to be used for testing. The collection
- * returned by this method should contain every element returned by
- * {@link #getFullElements()}. The default implementation, in fact,
- * simply invokes {@code addAll} on an empty collection with
- * the results of {@link #getFullElements()}. Override this default
- * if your collection doesn't support addAll.
+ * Returns a full collection to be used for testing. The collection
+ * returned by this method should contain every element returned by
+ * {@link #getFullElements()}. The default implementation, in fact,
+ * simply invokes {@code addAll} on an empty collection with
+ * the results of {@link #getFullElements()}. Override this default
+ * if your collection doesn't support addAll.
*/
public Collection makeFullCollection() {
final Collection c = makeObject();
@@ -541,9 +541,9 @@ public Collection makeFullCollection() {
public abstract Collection makeObject();
/**
- * Resets the {@link #collection} and {@link #confirmed} fields to empty
- * collections. Invoke this method before performing a modification
- * test.
+ * Resets the {@link #collection} and {@link #confirmed} fields to empty
+ * collections. Invoke this method before performing a modification
+ * test.
*/
public void resetEmpty() {
this.setCollection(makeObject());
@@ -551,9 +551,9 @@ public void resetEmpty() {
}
/**
- * Resets the {@link #collection} and {@link #confirmed} fields to full
- * collections. Invoke this method before performing a modification
- * test.
+ * Resets the {@link #collection} and {@link #confirmed} fields to full
+ * collections. Invoke this method before performing a modification
+ * test.
*/
public void resetFull() {
this.setCollection(makeFullCollection());
@@ -562,6 +562,7 @@ public void resetFull() {
/**
* Sets the collection.
+ *
* @param collection the Collection to set
*/
public void setCollection(final Collection collection) {
@@ -570,13 +571,13 @@ public void setCollection(final Collection collection) {
/**
* Sets the confirmed.
+ *
* @param confirmed the Collection to set
*/
public void setConfirmed(final Collection confirmed) {
this.confirmed = confirmed;
}
- // Tests
/**
* Tests {@link Collection#add(Object)}.
*/
diff --git a/src/test/java/org/apache/commons/collections4/collection/CompositeCollectionTest.java b/src/test/java/org/apache/commons/collections4/collection/CompositeCollectionTest.java
index 4a02113a47..b7116edd76 100644
--- a/src/test/java/org/apache/commons/collections4/collection/CompositeCollectionTest.java
+++ b/src/test/java/org/apache/commons/collections4/collection/CompositeCollectionTest.java
@@ -79,6 +79,7 @@ public Collection makeConfirmedCollection() {
public Collection makeConfirmedFullCollection() {
return new HashSet<>(Arrays.asList(getFullElements()));
}
+
/**
* Full collection consists of 4 collections, each with one element
*/
@@ -93,6 +94,7 @@ public Collection makeFullCollection() {
}
return compositeCollection;
}
+
/**
* Empty collection is empty composite
*/
diff --git a/src/test/java/org/apache/commons/collections4/functors/AbstractMockPredicateTest.java b/src/test/java/org/apache/commons/collections4/functors/AbstractMockPredicateTest.java
index ad6e28065c..b4bfeca14c 100644
--- a/src/test/java/org/apache/commons/collections4/functors/AbstractMockPredicateTest.java
+++ b/src/test/java/org/apache/commons/collections4/functors/AbstractMockPredicateTest.java
@@ -32,6 +32,7 @@
* provides methods to create and verify mock predicates to which to delegate.
*/
public abstract class AbstractMockPredicateTest {
+
/**
* Mock predicates created by a single test case which need to be verified after the test completes.
*/
diff --git a/src/test/java/org/apache/commons/collections4/iterators/ExtendedIteratorTest.java b/src/test/java/org/apache/commons/collections4/iterators/ExtendedIteratorTest.java
index 612bb60629..21ae019073 100644
--- a/src/test/java/org/apache/commons/collections4/iterators/ExtendedIteratorTest.java
+++ b/src/test/java/org/apache/commons/collections4/iterators/ExtendedIteratorTest.java
@@ -32,6 +32,7 @@
import org.junit.jupiter.api.Test;
class ExtendedIteratorTest {
+
/**
* Collection of {@link Integer}s
*/
diff --git a/src/test/java/org/apache/commons/collections4/list/AbstractListTest.java b/src/test/java/org/apache/commons/collections4/list/AbstractListTest.java
index 839b82d42e..f1dad5c1b6 100644
--- a/src/test/java/org/apache/commons/collections4/list/AbstractListTest.java
+++ b/src/test/java/org/apache/commons/collections4/list/AbstractListTest.java
@@ -167,10 +167,10 @@ public boolean supportsSet() {
}
/**
- * Traverses to the beginning of the given iterator.
+ * Traverses to the beginning of the given iterator.
*
- * @param iter the iterator to traverse
- * @param i the starting index
+ * @param iter the iterator to traverse
+ * @param i the starting index
*/
private void backwardTest(final ListIterator iter, int i) {
final List list = getCollection();
@@ -203,14 +203,14 @@ public BulkTest bulkTestListIterator() {
}
/**
- * Returns a {@link BulkTest} for testing {@link List#subList(int,int)}.
- * The returned bulk test will run through every {@code TestList}
- * method, including another {@code bulkTestSubList}.
- * Sublists are tested until the size of the sublist is less than 10.
- * Each sublist is 6 elements smaller than its parent list.
- * (By default this means that two rounds of sublists will be tested).
- * The verify() method is overloaded to test that the original list is
- * modified when the sublist is.
+ * Returns a {@link BulkTest} for testing {@link List#subList(int,int)}.
+ * The returned bulk test will run through every {@code TestList}
+ * method, including another {@code bulkTestSubList}.
+ * Sublists are tested until the size of the sublist is less than 10.
+ * Each sublist is 6 elements smaller than its parent list.
+ * (By default this means that two rounds of sublists will be tested).
+ * The verify() method is overloaded to test that the original list is
+ * modified when the sublist is.
*/
public BulkTest bulkTestSubList() {
if (getFullElements().length - 6 < 10) {
@@ -271,10 +271,10 @@ protected void failFastMethod(final List list, final Method m) {
}
/**
- * Traverses to the end of the given iterator.
+ * Traverses to the end of the given iterator.
*
- * @param iter the iterator to traverse
- * @param i the starting index
+ * @param iter the iterator to traverse
+ * @param i the starting index
*/
private void forwardTest(final ListIterator iter, int i) {
final List list = getCollection();
@@ -328,11 +328,11 @@ public boolean isEqualsCheckable() {
}
/**
- * Returns true if the collections produced by
- * {@link #makeObject()} and {@link #makeFullCollection()}
- * support the set operation.
- * Default implementation returns true. Override if your collection
- * class does not support set.
+ * Returns true if the collections produced by
+ * {@link #makeObject()} and {@link #makeFullCollection()}
+ * support the set operation.
+ * Default implementation returns true. Override if your collection
+ * class does not support set.
*/
public boolean isSetSupported() {
return true;
@@ -458,7 +458,7 @@ void testFullListSerialization() throws IOException, ClassNotFoundException {
}
/**
- * Tests {@link List#add(int,Object)}.
+ * Tests {@link List#add(int,Object)}.
*/
@Test
void testListAddByIndex() {
@@ -478,8 +478,8 @@ void testListAddByIndex() {
}
/**
- * Tests bounds checking for {@link List#add(int, Object)} on an
- * empty list.
+ * Tests bounds checking for {@link List#add(int, Object)} on an
+ * empty list.
*/
@Test
void testListAddByIndexBoundsChecking() {
@@ -507,8 +507,8 @@ void testListAddByIndexBoundsChecking() {
}
/**
- * Tests bounds checking for {@link List#add(int, Object)} on a
- * full list.
+ * Tests bounds checking for {@link List#add(int, Object)} on a
+ * full list.
*/
@Test
void testListAddByIndexBoundsChecking2() {
@@ -536,7 +536,7 @@ void testListAddByIndexBoundsChecking2() {
}
/**
- * Tests {@link List#equals(Object)}.
+ * Tests {@link List#equals(Object)}.
*/
@Test
void testListEquals() {
@@ -607,7 +607,7 @@ public int size() {
}
/**
- * Tests {@link List#get(int)}.
+ * Tests {@link List#get(int)}.
*/
@Test
void testListGetByIndex() {
@@ -621,8 +621,8 @@ void testListGetByIndex() {
}
/**
- * Tests bounds checking for {@link List#get(int)} on an
- * empty list.
+ * Tests bounds checking for {@link List#get(int)} on an
+ * empty list.
*/
@Test
void testListGetByIndexBoundsChecking() {
@@ -645,8 +645,8 @@ void testListGetByIndexBoundsChecking() {
}
/**
- * Tests bounds checking for {@link List#get(int)} on a
- * full list.
+ * Tests bounds checking for {@link List#get(int)} on a
+ * full list.
*/
@Test
void testListGetByIndexBoundsChecking2() {
@@ -666,7 +666,7 @@ void testListGetByIndexBoundsChecking2() {
}
/**
- * Tests {@link List#hashCode()}.
+ * Tests {@link List#hashCode()}.
*/
@Test
void testListHashCode() {
@@ -684,7 +684,7 @@ void testListHashCode() {
}
/**
- * Tests {@link List#indexOf}.
+ * Tests {@link List#indexOf}.
*/
@Test
void testListIndexOf() {
@@ -707,8 +707,8 @@ void testListIndexOf() {
}
/**
- * Tests the {@link ListIterator#add(Object)} method of the list
- * iterator.
+ * Tests the {@link ListIterator#add(Object)} method of the list
+ * iterator.
*/
@Test
void testListIteratorAdd() {
@@ -743,8 +743,8 @@ void testListIteratorAdd() {
}
/**
- * Tests the {@link ListIterator#set(Object)} method of the list
- * iterator.
+ * Tests the {@link ListIterator#set(Object)} method of the list
+ * iterator.
*/
@Test
void testListIteratorSet() {
@@ -767,7 +767,7 @@ void testListIteratorSet() {
}
/**
- * Tests {@link List#lastIndexOf}.
+ * Tests {@link List#lastIndexOf}.
*/
@Test
void testListLastIndexOf() {
@@ -790,7 +790,7 @@ void testListLastIndexOf() {
}
/**
- * Tests the read-only bits of {@link List#listIterator()}.
+ * Tests the read-only bits of {@link List#listIterator()}.
*/
@Test
void testListListIterator() {
@@ -800,7 +800,7 @@ void testListListIterator() {
}
/**
- * Tests the read-only bits of {@link List#listIterator(int)}.
+ * Tests the read-only bits of {@link List#listIterator(int)}.
*/
@Test
void testListListIteratorByIndex() {
@@ -945,7 +945,7 @@ void testListListIteratorPreviousRemovePrevious() {
}
/**
- * Tests {@link List#remove(int)}.
+ * Tests {@link List#remove(int)}.
*/
@Test
void testListRemoveByIndex() {
@@ -964,8 +964,8 @@ void testListRemoveByIndex() {
}
/**
- * Tests bounds checking for {@link List#remove(int)} on an
- * empty list.
+ * Tests bounds checking for {@link List#remove(int)} on an
+ * empty list.
*/
@Test
void testListRemoveByIndexBoundsChecking() {
@@ -992,8 +992,8 @@ void testListRemoveByIndexBoundsChecking() {
}
/**
- * Tests bounds checking for {@link List#remove(int)} on a
- * full list.
+ * Tests bounds checking for {@link List#remove(int)} on a
+ * full list.
*/
@Test
void testListRemoveByIndexBoundsChecking2() {
@@ -1017,7 +1017,7 @@ void testListRemoveByIndexBoundsChecking2() {
}
/**
- * Test {@link List#set(int,Object)}.
+ * Test {@link List#set(int,Object)}.
*/
@Test
void testListSetByIndex() {
@@ -1039,8 +1039,8 @@ void testListSetByIndex() {
}
/**
- * Tests bounds checking for {@link List#set(int,Object)} on an
- * empty list.
+ * Tests bounds checking for {@link List#set(int,Object)} on an
+ * empty list.
*/
@Test
void testListSetByIndexBoundsChecking() {
@@ -1068,8 +1068,8 @@ void testListSetByIndexBoundsChecking() {
}
/**
- * Tests bounds checking for {@link List#set(int,Object)} on a
- * full list.
+ * Tests bounds checking for {@link List#set(int,Object)} on a
+ * full list.
*/
@Test
void testListSetByIndexBoundsChecking2() {
@@ -1169,8 +1169,8 @@ void testListSubListFailFastOnRemove() {
}
/**
- * If {@link #isSetSupported()} returns false, tests that set operation
- * raises UnsupportedOperationException.
+ * If {@link #isSetSupported()} returns false, tests that set operation
+ * raises UnsupportedOperationException.
*/
@Test
void testUnsupportedSet() {
@@ -1187,8 +1187,8 @@ void testUnsupportedSet() {
}
/**
- * Verifies that the test list implementation matches the confirmed list
- * implementation.
+ * Verifies that the test list implementation matches the confirmed list
+ * implementation.
*/
@Override
@SuppressWarnings("unchecked")
diff --git a/src/test/java/org/apache/commons/collections4/list/SetUniqueListTest.java b/src/test/java/org/apache/commons/collections4/list/SetUniqueListTest.java
index 9cd1b4bd01..2a22a89c6d 100644
--- a/src/test/java/org/apache/commons/collections4/list/SetUniqueListTest.java
+++ b/src/test/java/org/apache/commons/collections4/list/SetUniqueListTest.java
@@ -42,6 +42,7 @@
public class SetUniqueListTest extends AbstractListTest {
final class SetUniqueList307 extends SetUniqueList {
+
/**
* Generated serial version ID.
*/
diff --git a/src/test/java/org/apache/commons/collections4/list/TreeListTest.java b/src/test/java/org/apache/commons/collections4/list/TreeListTest.java
index ec5b683e66..bff75d2bc7 100644
--- a/src/test/java/org/apache/commons/collections4/list/TreeListTest.java
+++ b/src/test/java/org/apache/commons/collections4/list/TreeListTest.java
@@ -19,6 +19,7 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import java.util.ArrayList;
import java.util.List;
@@ -202,16 +203,6 @@ void testIndexOf() {
assertEquals(0, l.indexOf("3"));
}
-// void testCheck() {
-// List l = makeEmptyList();
-// l.add("A1");
-// l.add("A2");
-// l.add("A3");
-// l.add("A4");
-// l.add("A5");
-// l.add("A6");
-// }
-
@Test
@SuppressWarnings("unchecked")
void testInsertBefore() {
@@ -222,6 +213,16 @@ void testInsertBefore() {
assertEquals("erna", l.get(1));
}
+// void testCheck() {
+// List l = makeEmptyList();
+// l.add("A1");
+// l.add("A2");
+// l.add("A3");
+// l.add("A4");
+// l.add("A5");
+// l.add("A6");
+// }
+
@Test
@SuppressWarnings("boxing") // OK in test code
void testIterationOrder() {
@@ -326,4 +327,15 @@ void testRemove() {
assertEquals("harald", l.get(i++));
}
+ @Test
+ void testTreeListIteratorConstruction() throws Throwable {
+ final TreeList treeList = new TreeList<>();
+ treeList.add("a");
+ treeList.add("b");
+ assertThrows(IndexOutOfBoundsException.class, () -> treeList.listIterator(3).previous());
+ assertThrows(IndexOutOfBoundsException.class, () -> new TreeList.TreeListIterator(treeList, 3));
+ // Test doesn't get to previous()
+ assertThrows(IndexOutOfBoundsException.class, () -> new TreeList.TreeListIterator(treeList, 3).previous());
+ }
+
}
diff --git a/src/test/java/org/apache/commons/collections4/map/AbstractMapTest.java b/src/test/java/org/apache/commons/collections4/map/AbstractMapTest.java
index 1fa6a52203..1c7ee770aa 100644
--- a/src/test/java/org/apache/commons/collections4/map/AbstractMapTest.java
+++ b/src/test/java/org/apache/commons/collections4/map/AbstractMapTest.java
@@ -164,6 +164,7 @@ public Map.Entry getEntry(final Iterator> itConfirmed, fin
}
// Have to implement manually; entrySet doesn't support addAll
+
/**
* {@inheritDoc}
*/
diff --git a/src/test/java/org/apache/commons/collections4/map/EmptyMapMutator.java b/src/test/java/org/apache/commons/collections4/map/EmptyMapMutator.java
index a9871f6672..75520d1e9e 100644
--- a/src/test/java/org/apache/commons/collections4/map/EmptyMapMutator.java
+++ b/src/test/java/org/apache/commons/collections4/map/EmptyMapMutator.java
@@ -25,6 +25,7 @@
* class also has to be serialized.
*/
final class EmptyMapMutator implements CompositeMap.MapMutator {
+
/** Serialization version */
private static final long serialVersionUID = -2729718980002476794L;
diff --git a/src/test/java/org/apache/commons/collections4/map/LRUMapTest.java b/src/test/java/org/apache/commons/collections4/map/LRUMapTest.java
index b15998dbe1..db65f2e2a7 100644
--- a/src/test/java/org/apache/commons/collections4/map/LRUMapTest.java
+++ b/src/test/java/org/apache/commons/collections4/map/LRUMapTest.java
@@ -612,6 +612,7 @@ public void run() {
map.entrySet().removeIf(entry -> entry.getValue() == this);
}
} catch (final InterruptedException e) {
+ interrupt();
fail("Unexpected InterruptedException");
}
if (i > 0) {
@@ -696,6 +697,7 @@ public void run() {
}
}
} catch (final InterruptedException e) {
+ interrupt();
fail("Unexpected InterruptedException");
}
if (i > 0) {
@@ -780,6 +782,7 @@ public void run() {
}
}
} catch (final InterruptedException e) {
+ interrupt();
fail("Unexpected InterruptedException");
}
if (i > 0) {
@@ -859,6 +862,7 @@ public void run() {
map.values().removeIf(thread1 -> thread1 == this);
}
} catch (final InterruptedException e) {
+ interrupt();
fail("Unexpected InterruptedException");
}
if (i > 0) {
diff --git a/src/test/java/org/apache/commons/collections4/multimap/AbstractMultiValuedMapTest.java b/src/test/java/org/apache/commons/collections4/multimap/AbstractMultiValuedMapTest.java
index ff6a7b152e..f6ec78ce00 100644
--- a/src/test/java/org/apache/commons/collections4/multimap/AbstractMultiValuedMapTest.java
+++ b/src/test/java/org/apache/commons/collections4/multimap/AbstractMultiValuedMapTest.java
@@ -435,7 +435,6 @@ public BulkTest bulkTestAsMap() {
return new MultiValuedMapAsMapTest();
}
- // Bulk Tests
/**
* Bulk test {@link MultiValuedMap#entries()}. This method runs through all
* of the tests in {@link AbstractCollectionTest}. After modification
diff --git a/src/test/java/org/apache/commons/collections4/multimap/ArrayListValuedHashMapTest.java b/src/test/java/org/apache/commons/collections4/multimap/ArrayListValuedHashMapTest.java
index 47e9a63e60..f65ee297c0 100644
--- a/src/test/java/org/apache/commons/collections4/multimap/ArrayListValuedHashMapTest.java
+++ b/src/test/java/org/apache/commons/collections4/multimap/ArrayListValuedHashMapTest.java
@@ -93,6 +93,19 @@ void testEqualsHashCodeContract() {
assertNotSame(map1.hashCode(), map2.hashCode());
}
+ @Test
+ void testInverted() {
+ final ArrayListValuedHashMap shopping = new ArrayListValuedHashMap<>(4);
+ shopping.put("Alice", "Bread");
+ shopping.put("Alice", "Milk");
+ shopping.put("Alice", "Milk");
+ shopping.put("Bob", "Pizza");
+ shopping.put("Bob", "Bread");
+ shopping.put("Bob", "Bread");
+ assertEquals("{Pizza=[Bob], Bread=[Bob, Bob, Alice], Milk=[Alice, Alice]}",
+ shopping.inverted().toString());
+ }
+
@Test
@SuppressWarnings("unchecked")
void testListValuedMapAdd() {
diff --git a/src/test/java/org/apache/commons/collections4/multimap/ArrayListValuedLinkedHashMapTest.java b/src/test/java/org/apache/commons/collections4/multimap/ArrayListValuedLinkedHashMapTest.java
index 74353b50ab..550a192409 100644
--- a/src/test/java/org/apache/commons/collections4/multimap/ArrayListValuedLinkedHashMapTest.java
+++ b/src/test/java/org/apache/commons/collections4/multimap/ArrayListValuedLinkedHashMapTest.java
@@ -99,6 +99,19 @@ void testEqualsHashCodeContract() {
assertNotSame(map1.hashCode(), map2.hashCode());
}
+ @Test
+ void testInverted() {
+ final ArrayListValuedLinkedHashMap shopping = new ArrayListValuedLinkedHashMap<>(4);
+ shopping.put("Alice", "Bread");
+ shopping.put("Alice", "Milk");
+ shopping.put("Alice", "Milk");
+ shopping.put("Bob", "Pizza");
+ shopping.put("Bob", "Bread");
+ shopping.put("Bob", "Bread");
+ assertEquals("{Bread=[Alice, Bob, Bob], Milk=[Alice, Alice], Pizza=[Bob]}",
+ shopping.inverted().toString());
+ }
+
@Test
@SuppressWarnings("unchecked")
void testListValuedMapAdd() {
diff --git a/src/test/java/org/apache/commons/collections4/multimap/HashSetValuedHashMapTest.java b/src/test/java/org/apache/commons/collections4/multimap/HashSetValuedHashMapTest.java
index 7b50d6cd13..419ae3814f 100644
--- a/src/test/java/org/apache/commons/collections4/multimap/HashSetValuedHashMapTest.java
+++ b/src/test/java/org/apache/commons/collections4/multimap/HashSetValuedHashMapTest.java
@@ -110,6 +110,19 @@ void testHashSetValueHashMap_1() {
assertEquals("{}", map3.toString());
}
+ @Test
+ void testInverted() {
+ final HashSetValuedHashMap dependencies = new HashSetValuedHashMap<>();
+ dependencies.put("commons-configuration2", "commons-logging");
+ dependencies.put("commons-configuration2", "commons-lang3");
+ dependencies.put("commons-configuration2", "commons-text");
+ dependencies.put("commons-beanutils", "commons-collections");
+ dependencies.put("commons-beanutils", "commons-logging");
+ final Set loggingUsages = dependencies.inverted().get("commons-logging");
+ assertEquals("[commons-beanutils, commons-configuration2]",
+ loggingUsages.toString());
+ }
+
@Test
@SuppressWarnings("unchecked")
void testSetValuedMapAdd() {
diff --git a/src/test/java/org/apache/commons/collections4/multimap/LinkedHashSetValuedLinkedHashMapTest.java b/src/test/java/org/apache/commons/collections4/multimap/LinkedHashSetValuedLinkedHashMapTest.java
index 2b37cb76d2..561432363b 100644
--- a/src/test/java/org/apache/commons/collections4/multimap/LinkedHashSetValuedLinkedHashMapTest.java
+++ b/src/test/java/org/apache/commons/collections4/multimap/LinkedHashSetValuedLinkedHashMapTest.java
@@ -96,6 +96,19 @@ void testHashSetValueHashMap_1() {
assertEquals("{}", map3.toString());
}
+ @Test
+ void testInverted() {
+ final LinkedHashSetValuedLinkedHashMap citiesLived = new LinkedHashSetValuedLinkedHashMap<>(4);
+ citiesLived.put("Alice", "N.Y.");
+ citiesLived.put("Alice", "L.A.");
+ citiesLived.put("Alice", "Chicago");
+ citiesLived.put("Bob", "N.Y.");
+ citiesLived.put("Cara", "L.A.");
+ citiesLived.put("Cara", "Chicago");
+ assertEquals("{N.Y.=[Alice, Bob], L.A.=[Alice, Cara], Chicago=[Alice, Cara]}",
+ citiesLived.inverted().toString());
+ }
+
@Test
void testLinkedHashSetValuedLinkedHashMap_2() {
final Map map = new HashMap<>();
diff --git a/src/test/java/org/apache/commons/collections4/multimap/TransformedMultiValuedMapTest.java b/src/test/java/org/apache/commons/collections4/multimap/TransformedMultiValuedMapTest.java
index 37ef87d8f0..d83b47108a 100644
--- a/src/test/java/org/apache/commons/collections4/multimap/TransformedMultiValuedMapTest.java
+++ b/src/test/java/org/apache/commons/collections4/multimap/TransformedMultiValuedMapTest.java
@@ -19,6 +19,7 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.Collection;
@@ -99,6 +100,11 @@ void testFactory_decorateTransform() {
assertTrue(transMap.get((K) "D").contains(Integer.valueOf(4)));
}
+ @Test
+ void testInvertedIsUnsupportedByDefault() {
+ assertThrows(UnsupportedOperationException.class, () -> makeObject().inverted());
+ }
+
@Test
@SuppressWarnings("unchecked")
void testKeyTransformedMap() {
diff --git a/src/test/java/org/apache/commons/collections4/trie/PatriciaTrieTest.java b/src/test/java/org/apache/commons/collections4/trie/PatriciaTrieTest.java
index 9da685ef53..e1c7547605 100644
--- a/src/test/java/org/apache/commons/collections4/trie/PatriciaTrieTest.java
+++ b/src/test/java/org/apache/commons/collections4/trie/PatriciaTrieTest.java
@@ -33,6 +33,14 @@
import java.util.NoSuchElementException;
import java.util.Set;
import java.util.SortedMap;
+import java.util.concurrent.CyclicBarrier;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
import org.apache.commons.collections4.Trie;
import org.apache.commons.collections4.map.AbstractSortedMapTest;
@@ -40,7 +48,7 @@
import org.junit.jupiter.api.Test;
/**
- * JUnit tests for the PatriciaTrie.
+ * Tests {@link PatriciaTrie}.
*
* @param the value type.
*/
@@ -437,6 +445,229 @@ void testPrefixMapSizes2() {
assertTrue(trie.prefixMap(prefixString).containsKey(longerString));
}
+ @Test
+ void testSubmap() {
+ final PatriciaTrie trie = new PatriciaTrie<>();
+ trie.put("ga", "ga");
+ trie.put("gb", "gb");
+ trie.put("gc", "gc");
+ trie.put("gd", "gd");
+ trie.put("ge", "ge");
+
+ // subMap should be entire trie
+ SortedMap subMap = trie.subMap("a", "z");
+ assertEquals(5, subMap.size());
+ assertEquals("ga", subMap.get("ga"));
+ assertEquals("gb", subMap.get("gb"));
+ assertEquals("gc", subMap.get("gc"));
+ assertEquals("gd", subMap.get("gd"));
+ assertEquals("ge", subMap.get("ge"));
+
+ // subMap should be empty
+ subMap = trie.subMap("a", "a");
+ assertEquals(0, subMap.size());
+
+ // subMap() is not inclusive of the second key
+ // subMap should be 4 entries only - "ge" excluded
+ subMap = trie.subMap("ga", "ge");
+ assertEquals(4, subMap.size());
+ assertEquals("ga", subMap.get("ga"));
+ assertEquals("gb", subMap.get("gb"));
+ assertEquals("gc", subMap.get("gc"));
+ assertEquals("gd", subMap.get("gd"));
+ assertNull(subMap.get("ge"));
+
+ // subMap should be 5 entries
+ subMap = trie.subMap("ga", "gf");
+ assertEquals(5, subMap.size());
+ assertEquals("ga", subMap.get("ga"));
+ assertEquals("gb", subMap.get("gb"));
+ assertEquals("gc", subMap.get("gc"));
+ assertEquals("gd", subMap.get("gd"));
+ assertEquals("ge", subMap.get("ge"));
+
+ // subMap should be 4 entries - "ga" excluded
+ subMap = trie.subMap("gb", "z");
+ assertEquals(4, subMap.size());
+ assertNull(subMap.get("ga"));
+ assertEquals("gb", subMap.get("gb"));
+ assertEquals("gc", subMap.get("gc"));
+ assertEquals("gd", subMap.get("gd"));
+ assertEquals("ge", subMap.get("ge"));
+
+
+ // subMap should be 1 entry - "gc" only
+ subMap = trie.subMap("gc", "gd");
+ assertEquals(1, subMap.size());
+ assertNull(subMap.get("ga"));
+ assertNull(subMap.get("gb"));
+ assertEquals("gc", subMap.get("gc"));
+ assertNull(subMap.get("gd"));
+ assertNull(subMap.get("ge"));
+ }
+
+ @Test
+ void testTailMap() {
+ final PatriciaTrie trie = new PatriciaTrie<>();
+ trie.put("ga", "ga");
+ trie.put("gb", "gb");
+ trie.put("gc", "gc");
+ trie.put("gd", "gd");
+ trie.put("ge", "ge");
+
+ // tailMap should be entire trie
+ SortedMap tailMap = trie.tailMap("a");
+ assertEquals(5, tailMap.size());
+ assertEquals("ga", tailMap.get("ga"));
+ assertEquals("gb", tailMap.get("gb"));
+ assertEquals("gc", tailMap.get("gc"));
+ assertEquals("gd", tailMap.get("gd"));
+ assertEquals("ge", tailMap.get("ge"));
+
+ // tailMap should be empty
+ tailMap = trie.tailMap("z");
+ assertEquals(0, tailMap.size());
+
+ // tailMap is inclusive of the search key
+ // tailMap should be the entire trie
+ tailMap = trie.tailMap("ga");
+ assertEquals(5, tailMap.size());
+ assertEquals("ga", tailMap.get("ga"));
+ assertEquals("gb", tailMap.get("gb"));
+ assertEquals("gc", tailMap.get("gc"));
+ assertEquals("gd", tailMap.get("gd"));
+ assertEquals("ge", tailMap.get("ge"));
+
+ // tailMap should be single entry "ge"
+ tailMap = trie.tailMap("ge");
+ assertEquals(1, tailMap.size());
+ assertNull(tailMap.get("ga"));
+ assertNull(tailMap.get("gb"));
+ assertNull(tailMap.get("gc"));
+ assertNull(tailMap.get("gd"));
+ assertEquals("ge", tailMap.get("ge"));
+ }
+
+ @Test
+ void testHeadMap() {
+ final PatriciaTrie trie = new PatriciaTrie<>();
+ trie.put("ga", "ga");
+ trie.put("gb", "gb");
+ trie.put("gc", "gc");
+ trie.put("gd", "gd");
+ trie.put("ge", "ge");
+
+ // headMap should be entire trie
+ SortedMap headMap = trie.headMap("z");
+ assertEquals(5, headMap.size());
+ assertEquals("ga", headMap.get("ga"));
+ assertEquals("gb", headMap.get("gb"));
+ assertEquals("gc", headMap.get("gc"));
+ assertEquals("gd", headMap.get("gd"));
+ assertEquals("ge", headMap.get("ge"));
+
+ // headMap should be empty
+ headMap = trie.headMap("a");
+ assertEquals(0, headMap.size());
+
+ // headMap() is not inclusive of the key
+ // headMap should be 4 entries only - "ge" excluded
+ headMap = trie.headMap("ge");
+ assertEquals(4, headMap.size());
+ assertEquals("ga", headMap.get("ga"));
+ assertEquals("gb", headMap.get("gb"));
+ assertEquals("gc", headMap.get("gc"));
+ assertEquals("gd", headMap.get("gd"));
+ assertNull(headMap.get("ge"));
+
+ // headMap should be 5 entries
+ headMap = trie.headMap("gf");
+ assertEquals(5, headMap.size());
+ assertEquals("ga", headMap.get("ga"));
+ assertEquals("gb", headMap.get("gb"));
+ assertEquals("gc", headMap.get("gc"));
+ assertEquals("gd", headMap.get("gd"));
+ assertEquals("ge", headMap.get("ge"));
+
+ // headMap should be 1 entry - "ga" only
+ headMap = trie.headMap("gb");
+ assertEquals(1, headMap.size());
+ assertEquals("ga", headMap.get("ga"));
+ assertNull(headMap.get("gb"));
+ assertNull(headMap.get("gc"));
+ assertNull(headMap.get("gd"));
+ assertNull(headMap.get("ge"));
+ }
+
+
+ @Test
+ void testConcurrentTrieIterationAndSubMapIteration() throws InterruptedException, ExecutionException, TimeoutException {
+ final PatriciaTrie trie = new PatriciaTrie<>();
+ // populate with enough entries to make concurrent collisions likely
+ // call subMap with both keys missing to ensure phantom node addition done twice
+ final int subKeyFirst = 1;
+ final int subKeySecond = 4;
+ final String subKeyFirstStr = String.format("key%04d", subKeyFirst);
+ final String subKeySecondStr = String.format("key%04d", subKeySecond);
+ for (int i = 0; i <= 501; i++) {
+ if (i != subKeyFirst && i != subKeySecond) {
+ trie.put(String.format("key%04d", i), i);
+ }
+ }
+
+ final int iterations = 100;
+ final CyclicBarrier barrier = new CyclicBarrier(2);
+
+ final ExecutorService executor = Executors.newFixedThreadPool(2);
+ try {
+ // Thread 1: repeatedly iterate the entire trie
+ final Future> iteratorTask = executor.submit(() -> {
+ barrier.await(1, TimeUnit.SECONDS);
+ for (int i = 0; i < iterations && !Thread.currentThread().isInterrupted(); i++) {
+ int count = 0;
+ for (final Map.Entry entry : trie.entrySet()) {
+ // verify the iterated keys and values are not from the phantom node
+ assertNotNull(entry.getKey());
+ assertNotNull(entry.getValue());
+ count++;
+ }
+ assertEquals(500, count, "Iterator skipped or duplicated entries");
+ }
+ return null;
+ });
+
+ // Thread 2: repeatedly create and iterate subMap views
+ // (this triggers ceilingEntry with keys NOT in the trie)
+ final Future> subMapTask = executor.submit(() -> {
+ barrier.await(1, TimeUnit.SECONDS);
+ for (int i = 0; i < iterations && !Thread.currentThread().isInterrupted(); i++) {
+ // Use boundary keys that do NOT exist in the trie
+ // to force the ceiling/floor walk algorithm
+ final SortedMap sub = trie.subMap(subKeyFirstStr, subKeySecondStr);
+ int count = 0;
+ for (final Map.Entry entry : sub.entrySet()) {
+ // verify the iterated keys and values are not from the phantom node
+ assertNotNull(entry.getKey());
+ assertNotNull(entry.getValue());
+ count++;
+ }
+ assertEquals(2, count, "subMap returned wrong number of entries");
+ }
+ return null;
+ });
+
+ // get() unwraps ExecutionException
+ // if either task threw an exception or an assertion Error, (or any Throwable),
+ // then the original exception propagates with its full stacktrace
+ // and TimeoutException surfaces hangs
+ subMapTask.get(10, TimeUnit.SECONDS);
+ iteratorTask.get(10, TimeUnit.SECONDS);
+ } finally {
+ executor.shutdownNow();
+ executor.awaitTermination(5, TimeUnit.SECONDS);
+ }
+ }
+
// void testCreate() throws Exception {
// resetEmpty();
// writeExternalFormToDisk(