Merge branch 'pr-217'

This closes #217
This commit is contained in:
Bruno P. Kinoshita 2021-03-05 08:42:24 +13:00
commit 86733aae3a
8 changed files with 49 additions and 26 deletions

View File

@ -256,6 +256,9 @@
<action type="update" dev="kinow" due-to="Dependabot">
Bump commons-lang3 from 3.11 to 3.12.0 #219.
</action>
<action issue="COLLECTIONS-785" type="update" dev="kinow" due-to="Arturo Bernal">
Add new variables to oac.collections4.CollectionUtils and use them in the code base.
</action>
</release>
<release version="4.4" date="2019-07-05" description="Maintenance release.">
<action issue="COLLECTIONS-710" dev="ggregory" type="fix" due-to="Yu Shi, Gary Gregory">

View File

@ -63,6 +63,33 @@ public class CollectionUtils {
*/
public static final int INDEX_NOT_FOUND = -1;
/**
* Default prefix used while converting an Iterator to its String representation.
*
* @since 4.5
*/
public static final String DEFAULT_TOSTRING_PREFIX = "[";
/**
* Default suffix used while converting an Iterator to its String representation.
*
* @since 4.5
*/
public static final String DEFAULT_TOSTRING_SUFFIX = "]";
/**
* A String for Colon (":").
*
* @since 4.5
*/
public static final String COLON = ":";
/**
* A String for Comma (",").
*
* @since 4.5
*/
public static final String COMMA = ",";
/**
* Helper class to easily access cardinality properties of two collections.
* @param <O> the element type

View File

@ -105,17 +105,6 @@ public class IteratorUtils {
*/
@SuppressWarnings("rawtypes")
public static final OrderedMapIterator EMPTY_ORDERED_MAP_ITERATOR = EmptyOrderedMapIterator.INSTANCE;
/**
* Default prefix used while converting an Iterator to its String representation.
*/
private static final String DEFAULT_TOSTRING_PREFIX = "[";
/**
* Default suffix used while converting an Iterator to its String representation.
*/
private static final String DEFAULT_TOSTRING_SUFFIX = "]";
/**
* Default delimiter used to delimit elements while converting an Iterator
* to its String representation.
@ -1405,8 +1394,8 @@ public class IteratorUtils {
*/
public static <E> String toString(final Iterator<E> iterator) {
return toString(iterator, TransformerUtils.stringValueTransformer(),
DEFAULT_TOSTRING_DELIMITER, DEFAULT_TOSTRING_PREFIX,
DEFAULT_TOSTRING_SUFFIX);
DEFAULT_TOSTRING_DELIMITER, CollectionUtils.DEFAULT_TOSTRING_PREFIX,
CollectionUtils.DEFAULT_TOSTRING_SUFFIX);
}
/**
@ -1427,7 +1416,7 @@ public class IteratorUtils {
public static <E> String toString(final Iterator<E> iterator,
final Transformer<? super E, String> transformer) {
return toString(iterator, transformer, DEFAULT_TOSTRING_DELIMITER,
DEFAULT_TOSTRING_PREFIX, DEFAULT_TOSTRING_SUFFIX);
CollectionUtils.DEFAULT_TOSTRING_PREFIX, CollectionUtils.DEFAULT_TOSTRING_SUFFIX);
}
/**

View File

@ -28,6 +28,7 @@ import java.util.Map.Entry;
import java.util.Set;
import org.apache.commons.collections4.Bag;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.set.UnmodifiableSet;
/**
@ -603,19 +604,19 @@ public abstract class AbstractMapBag<E> implements Bag<E> {
return "[]";
}
final StringBuilder buf = new StringBuilder();
buf.append('[');
buf.append(CollectionUtils.DEFAULT_TOSTRING_PREFIX);
final Iterator<E> it = uniqueSet().iterator();
while (it.hasNext()) {
final Object current = it.next();
final int count = getCount(current);
buf.append(count);
buf.append(':');
buf.append(CollectionUtils.COLON);
buf.append(current);
if (it.hasNext()) {
buf.append(',');
buf.append(CollectionUtils.COMMA);
}
}
buf.append(']');
buf.append(CollectionUtils.DEFAULT_TOSTRING_SUFFIX);
return buf.toString();
}

View File

@ -407,7 +407,7 @@ public abstract class AbstractLinkedList<E> implements List<E> {
return "[]";
}
final StringBuilder buf = new StringBuilder(16 * size());
buf.append('[');
buf.append(CollectionUtils.DEFAULT_TOSTRING_PREFIX);
final Iterator<E> it = iterator();
boolean hasNext = it.hasNext();
@ -419,7 +419,7 @@ public abstract class AbstractLinkedList<E> implements List<E> {
buf.append(", ");
}
}
buf.append(']');
buf.append(CollectionUtils.DEFAULT_TOSTRING_SUFFIX);
return buf.toString();
}

View File

@ -26,6 +26,7 @@ import java.util.ListIterator;
import java.util.NoSuchElementException;
import java.util.Objects;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.OrderedIterator;
/**
@ -965,11 +966,11 @@ public class TreeList<E> extends AbstractList<E> {
return new StringBuilder()
.append("AVLNode(")
.append(relativePosition)
.append(',')
.append(CollectionUtils.COMMA)
.append(left != null)
.append(',')
.append(CollectionUtils.COMMA)
.append(value)
.append(',')
.append(CollectionUtils.COMMA)
.append(getRightSubTree() != null)
.append(", faedelung ")
.append(rightIsNext)

View File

@ -30,6 +30,7 @@ import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Set;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.IterableMap;
import org.apache.commons.collections4.KeyValue;
import org.apache.commons.collections4.MapIterator;
@ -1404,7 +1405,7 @@ public class AbstractHashedMap<K, V> extends AbstractMap<K, V> implements Iterab
hasNext = it.hasNext();
if (hasNext) {
buf.append(',').append(' ');
buf.append(CollectionUtils.COMMA).append(' ');
}
}

View File

@ -28,6 +28,7 @@ import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Set;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.IterableMap;
import org.apache.commons.collections4.MapIterator;
import org.apache.commons.collections4.ResettableIterator;
@ -1262,12 +1263,12 @@ public class Flat3Map<K, V> implements IterableMap<K, V>, Serializable, Cloneabl
buf.append(key3 == this ? "(this Map)" : key3);
buf.append('=');
buf.append(value3 == this ? "(this Map)" : value3);
buf.append(',');
buf.append(CollectionUtils.COMMA);
case 2:
buf.append(key2 == this ? "(this Map)" : key2);
buf.append('=');
buf.append(value2 == this ? "(this Map)" : value2);
buf.append(',');
buf.append(CollectionUtils.COMMA);
case 1:
buf.append(key1 == this ? "(this Map)" : key1);
buf.append('=');