Skip to content

Commit

Permalink
Javadoc
Browse files Browse the repository at this point in the history
- Close HTML tags
- Use longer lines
- Whitespace before tags
- Remove dead inline comments
= Add missing paragraph tags
  • Loading branch information
garydgregory committed Oct 20, 2024
1 parent a7e9288 commit 0165505
Show file tree
Hide file tree
Showing 25 changed files with 113 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ public static <E> Closure<E> nopClosure() {
* closure is called. The default closure is set in the map with a
* null key. The ordering is that of the iterator() method on the entryset
* collection of the map.
* </p>
*
* @see org.apache.commons.collections4.functors.SwitchClosure
*
Expand All @@ -275,6 +276,7 @@ public static <E> Closure<E> switchClosure(final Map<Predicate<E>, Closure<E>> p
* The closure at array location 0 is called if the predicate at array
* location 0 returned true. Each predicate is evaluated
* until one returns true.
* </p>
*
* @see org.apache.commons.collections4.functors.SwitchClosure
*
Expand All @@ -299,6 +301,7 @@ public static <E> Closure<E> switchClosure(final Predicate<? super E>[] predicat
* location 0 returned true. Each predicate is evaluated
* until one returns true. If no predicates evaluate to true, the default
* closure is called.
* </p>
*
* @see org.apache.commons.collections4.functors.SwitchClosure
*
Expand All @@ -325,6 +328,7 @@ public static <E> Closure<E> switchClosure(final Predicate<? super E>[] predicat
* is called if the input object equals the key. If there is no match, the
* default closure is called. The default closure is set in the map
* using a null key.
* </p>
*
* @see org.apache.commons.collections4.functors.SwitchClosure
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ public void setCardinality(final O obj, final int count) {
* @since 4.5.0
*/
public static final int INDEX_NOT_FOUND = -1;

/**
* Default prefix used while converting an Iterator to its String representation.
*
Expand Down Expand Up @@ -461,11 +462,9 @@ public static <O> List<O> collate(final Iterable<? extends O> a, final Iterable<
*/
public static <O> List<O> collate(final Iterable<? extends O> iterableA, final Iterable<? extends O> iterableB,
final Comparator<? super O> comparator, final boolean includeDuplicates) {

Objects.requireNonNull(iterableA, "iterableA");
Objects.requireNonNull(iterableB, "iterableB");
Objects.requireNonNull(comparator, "comparator");

// if both Iterables are a Collection, we can estimate the size
final int totalSize = iterableA instanceof Collection<?> && iterableB instanceof Collection<?> ?
Math.max(1, ((Collection<?>) iterableA).size() + ((Collection<?>) iterableB).size()) : 10;
Expand All @@ -475,7 +474,6 @@ public static <O> List<O> collate(final Iterable<? extends O> iterableA, final I
return IteratorUtils.toList(iterator, totalSize);
}
final ArrayList<O> mergedList = new ArrayList<>(totalSize);

O lastItem = null;
while (iterator.hasNext()) {
final O item = iterator.next();
Expand All @@ -484,7 +482,6 @@ public static <O> List<O> collate(final Iterable<? extends O> iterableA, final I
}
lastItem = item;
}

mergedList.trimToSize();
return mergedList;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public static <T> Iterable<T> asIterable(final Enumeration<T> enumeration) {
* <p>
* The Enumeration is advanced to {@code index} (or to the end, if
* {@code index} exceeds the number of entries) as a side effect of this method.
* </p>
*
* @param e the enumeration to get a value from
* @param index the index to get
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
* <p>
* Since v4.1 only factories which are considered to be safe are
* Serializable. Factories considered to be unsafe for serialization are:
* </p>
* <ul>
* <li>Prototype
* <li>Instantiate
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/org/apache/commons/collections4/FluentIterable.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public static <T> FluentIterable<T> empty() {
* <p>
* The returned iterable's iterator supports {@code remove()} when the
* corresponding input iterator supports it.
* </p>
*
* @param <T> the element type
* @param iterable the iterable to wrap into a FluentIterable, may not be null
Expand All @@ -102,6 +103,7 @@ public static <T> FluentIterable<T> of(final Iterable<T> iterable) {
* Creates a new FluentIterable of the single provided element.
* <p>
* The returned iterable's iterator does not support {@code remove()}.
* </p>
*
* @param <T> the element type
* @param singleton the singleton element
Expand All @@ -115,6 +117,7 @@ public static <T> FluentIterable<T> of(final T singleton) {
* Creates a new FluentIterable from the provided elements.
* <p>
* The returned iterable's iterator does not support {@code remove()}.
* </p>
*
* @param <T> the element type
* @param elements the elements to be contained in the FluentIterable
Expand Down Expand Up @@ -147,6 +150,7 @@ private FluentIterable(final Iterable<E> iterable) {
* provided predicate.
* <p>
* A {@code null} or empty iterable returns true.
* </p>
*
* @param predicate the predicate to use, may not be null
* @return true if all elements contained in this iterable match the predicate,
Expand All @@ -161,6 +165,7 @@ public boolean allMatch(final Predicate<? super E> predicate) {
* Checks if this iterable contains any element matching the provided predicate.
* <p>
* A {@code null} or empty iterable returns false.
* </p>
*
* @param predicate the predicate to use, may not be null
* @return true if at least one element contained in this iterable matches the predicate,
Expand Down Expand Up @@ -211,13 +216,15 @@ public Enumeration<E> asEnumeration() {
* elements of the current and provided iterable in natural order.
* <p>
* Example: natural ordering
* </p>
* <ul>
* <li>this contains elements [1, 3, 5, 7]
* <li>other contains elements [2, 4, 6, 8]
* </ul>
* <p>
* The returned iterable will traverse the elements in the following
* order: [1, 2, 3, 4, 5, 6, 7, 8]
* </p>
*
* @param other the other iterable to collate, may not be null
* @return a new iterable, collating this iterable with the other in natural order
Expand All @@ -234,13 +241,15 @@ public FluentIterable<E> collate(final Iterable<? extends E> other) {
* ordering defined by a comparator.
* <p>
* Example: descending order
* </p>
* <ul>
* <li>this contains elements [7, 5, 3, 1]
* <li>other contains elements [8, 6, 4, 2]
* </ul>
* <p>
* The returned iterable will traverse the elements in the following
* order: [8, 7, 6, 5, 4, 3, 2, 1]
* </p>
*
* @param comparator the comparator to define an ordering, may be null,
* in which case natural ordering will be used
Expand Down Expand Up @@ -282,10 +291,12 @@ public void copyInto(final Collection<? super E> collection) {
* to the originating iterables and/or iterators.
* <p>
* Calling this method is equivalent to:
* </p>
* <pre>
* FluentIterable&lt;E&gt; someIterable = ...;
* FluentIterable.of(someIterable.toList());
* </pre>
* </p>
*
* @return a new iterable with the same contents as this iterable
*/
Expand Down Expand Up @@ -416,6 +427,7 @@ public E[] toArray(final Class<E> arrayClass) {
* by traversing its iterator.
* <p>
* The returned list is guaranteed to be mutable.
* </p>
*
* @return a list of the iterable contents
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public interface IterableGet<K, V> extends Get<K, V> {
* <p>
* A map iterator is an efficient way of iterating over maps.
* There is no need to access the entry set or use Map Entry objects.
* </p>
* <pre>
* IterableMap&lt;String,Integer&gt; map = new HashedMap&lt;String,Integer&gt;();
* MapIterator&lt;String,Integer&gt; it = map.mapIterator();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,6 @@ public static <E> Iterator<E> collatedIterator(final Comparator<? super E> compa
return new CollatingIterator<>(comp, iterators);
}

// Collated
/**
* Gets an iterator that provides an ordered iteration over the elements
* contained in a collection of ordered {@link Iterator}s.
Expand Down Expand Up @@ -1070,7 +1069,6 @@ public static NodeListIterator nodeListIterator(final NodeList nodeList) {
return new NodeListIterator(Objects.requireNonNull(nodeList, "nodeList"));
}

// Object Graph
/**
* Gets an iterator that operates over an object graph.
* <p>
Expand Down
Loading

0 comments on commit 0165505

Please sign in to comment.