Author: bayard
Date: Sat Jun 19 20:30:20 2010
New Revision: 956291
URL: http://svn.apache.org/viewvc?rev=956291&view=rev
Log:
Applying some of the refactorings from COLLECTIONS-312
Modified:
commons/proper/collections/trunk/src/java/org/apache/commons/collections/CollectionUtils.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/ExtendedProperties.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/MapUtils.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/bag/AbstractMapBag.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/comparators/ComparatorChain.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/comparators/ReverseComparator.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/EnumerationIterator.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/ObjectGraphIterator.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/UnmodifiableIterator.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/UnmodifiableMapIterator.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/list/SetUniqueList.java
commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/AbstractReferenceMap.java
Modified:
commons/proper/collections/trunk/src/java/org/apache/commons/collections/CollectionUtils.java
URL:
http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/CollectionUtils.java?rev=956291&r1=956290&r2=956291&view=diff
==============================================================================
---
commons/proper/collections/trunk/src/java/org/apache/commons/collections/CollectionUtils.java
(original)
+++
commons/proper/collections/trunk/src/java/org/apache/commons/collections/CollectionUtils.java
Sat Jun 19 20:30:20 2010
@@ -755,7 +755,7 @@ public class CollectionUtils {
* @since Commons Collections 3.2
*/
public static <T> boolean addIgnoreNull(Collection<T> collection, T
object) {
- return (object == null ? false : collection.add(object));
+ return (object != null && collection.add(object));
}
/**
Modified:
commons/proper/collections/trunk/src/java/org/apache/commons/collections/ExtendedProperties.java
URL:
http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/ExtendedProperties.java?rev=956291&r1=956290&r2=956291&view=diff
==============================================================================
---
commons/proper/collections/trunk/src/java/org/apache/commons/collections/ExtendedProperties.java
(original)
+++
commons/proper/collections/trunk/src/java/org/apache/commons/collections/ExtendedProperties.java
Sat Jun 19 20:30:20 2010
@@ -262,7 +262,7 @@ public class ExtendedProperties extends
}
throw new IllegalStateException(
- "infinite loop in property interpolation of " +
initialBase + ": " + priorVariableSb.toString());
+ "infinite loop in property interpolation of " +
initialBase + ": " + priorVariableSb);
}
// otherwise, add this variable to the interpolation list.
else {
@@ -577,7 +577,7 @@ public class ExtendedProperties extends
if (includeProperty != null &&
key.equalsIgnoreCase(includeProperty)) {
// Recursively load properties files.
- File file = null;
+ File file;
if (value.startsWith(fileSeparator)) {
// We have an absolute path so we'll use this
@@ -989,7 +989,7 @@ public class ExtendedProperties extends
if (equalSign > 0) {
String pkey = token.substring(0, equalSign).trim();
String pvalue = token.substring(equalSign + 1).trim();
- props.put(pkey, pvalue);
+ props.setProperty(pkey, pvalue);
} else {
throw new IllegalArgumentException('\'' + token + "' does not
contain " + "an equals sign");
}
@@ -1186,7 +1186,7 @@ public class ExtendedProperties extends
} else if (value instanceof String) {
String s = testBoolean((String) value);
- Boolean b = new Boolean(s);
+ Boolean b = Boolean.valueOf(s);
super.put(key, b);
return b;
Modified:
commons/proper/collections/trunk/src/java/org/apache/commons/collections/MapUtils.java
URL:
http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/MapUtils.java?rev=956291&r1=956290&r2=956291&view=diff
==============================================================================
---
commons/proper/collections/trunk/src/java/org/apache/commons/collections/MapUtils.java
(original)
+++
commons/proper/collections/trunk/src/java/org/apache/commons/collections/MapUtils.java
Sat Jun 19 20:30:20 2010
@@ -168,7 +168,7 @@ public class MapUtils {
return (Boolean) answer;
}
if (answer instanceof String) {
- return new Boolean((String) answer);
+ return Boolean.valueOf((String) answer);
}
if (answer instanceof Number) {
Number n = (Number) answer;
Modified:
commons/proper/collections/trunk/src/java/org/apache/commons/collections/bag/AbstractMapBag.java
URL:
http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/bag/AbstractMapBag.java?rev=956291&r1=956290&r2=956291&view=diff
==============================================================================
---
commons/proper/collections/trunk/src/java/org/apache/commons/collections/bag/AbstractMapBag.java
(original)
+++
commons/proper/collections/trunk/src/java/org/apache/commons/collections/bag/AbstractMapBag.java
Sat Jun 19 20:30:20 2010
@@ -179,8 +179,8 @@ public abstract class AbstractMapBag<E>
* Inner class iterator for the Bag.
*/
static class BagIterator<E> implements Iterator<E> {
- private AbstractMapBag<E> parent;
- private Iterator<Map.Entry<E, MutableInteger>> entryIterator;
+ private final AbstractMapBag<E> parent;
+ private final Iterator<Map.Entry<E, MutableInteger>> entryIterator;
private Map.Entry<E, MutableInteger> current;
private int itemCount;
private final int mods;
Modified:
commons/proper/collections/trunk/src/java/org/apache/commons/collections/comparators/ComparatorChain.java
URL:
http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/comparators/ComparatorChain.java?rev=956291&r1=956290&r2=956291&view=diff
==============================================================================
---
commons/proper/collections/trunk/src/java/org/apache/commons/collections/comparators/ComparatorChain.java
(original)
+++
commons/proper/collections/trunk/src/java/org/apache/commons/collections/comparators/ComparatorChain.java
Sat Jun 19 20:30:20 2010
@@ -95,7 +95,7 @@ public class ComparatorChain<E> implemen
* @param reverse false = forward sort; true = reverse sort
*/
public ComparatorChain(Comparator<E> comparator, boolean reverse) {
- comparatorChain = new ArrayList<Comparator<E>>();
+ comparatorChain = new ArrayList<Comparator<E>>(1);
comparatorChain.add(comparator);
orderingBits = new BitSet(1);
if (reverse == true) {
Modified:
commons/proper/collections/trunk/src/java/org/apache/commons/collections/comparators/ReverseComparator.java
URL:
http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/comparators/ReverseComparator.java?rev=956291&r1=956290&r2=956291&view=diff
==============================================================================
---
commons/proper/collections/trunk/src/java/org/apache/commons/collections/comparators/ReverseComparator.java
(original)
+++
commons/proper/collections/trunk/src/java/org/apache/commons/collections/comparators/ReverseComparator.java
Sat Jun 19 20:30:20 2010
@@ -38,7 +38,7 @@ public class ReverseComparator<E> implem
private static final long serialVersionUID = 2858887242028539265L;
/** The comparator being decorated. */
- private Comparator<E> comparator;
+ private final Comparator<E> comparator;
//-----------------------------------------------------------------------
/**
Modified:
commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/EnumerationIterator.java
URL:
http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/EnumerationIterator.java?rev=956291&r1=956290&r2=956291&view=diff
==============================================================================
---
commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/EnumerationIterator.java
(original)
+++
commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/EnumerationIterator.java
Sat Jun 19 20:30:20 2010
@@ -33,7 +33,7 @@ import java.util.Iterator;
public class EnumerationIterator<E> implements Iterator<E> {
/** The collection to remove elements from */
- private Collection<? super E> collection;
+ private final Collection<? super E> collection;
/** The enumeration being converted */
private Enumeration<? extends E> enumeration;
/** The last object retrieved */
Modified:
commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/ObjectGraphIterator.java
URL:
http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/ObjectGraphIterator.java?rev=956291&r1=956290&r2=956291&view=diff
==============================================================================
---
commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/ObjectGraphIterator.java
(original)
+++
commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/ObjectGraphIterator.java
Sat Jun 19 20:30:20 2010
@@ -82,7 +82,7 @@ public class ObjectGraphIterator<E> impl
/** The root object in the tree */
protected E root;
/** The transformer to use */
- protected Transformer<? super E, ? extends E> transformer;
+ protected final Transformer<? super E, ? extends E> transformer;
/** Whether there is another element in the iteration */
protected boolean hasNext = false;
Modified:
commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/UnmodifiableIterator.java
URL:
http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/UnmodifiableIterator.java?rev=956291&r1=956290&r2=956291&view=diff
==============================================================================
---
commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/UnmodifiableIterator.java
(original)
+++
commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/UnmodifiableIterator.java
Sat Jun 19 20:30:20 2010
@@ -33,7 +33,7 @@ import org.apache.commons.collections.Un
public final class UnmodifiableIterator<E> implements Iterator<E>,
Unmodifiable {
/** The iterator being decorated */
- private Iterator<E> iterator;
+ private final Iterator<E> iterator;
//-----------------------------------------------------------------------
/**
Modified:
commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/UnmodifiableMapIterator.java
URL:
http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/UnmodifiableMapIterator.java?rev=956291&r1=956290&r2=956291&view=diff
==============================================================================
---
commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/UnmodifiableMapIterator.java
(original)
+++
commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/UnmodifiableMapIterator.java
Sat Jun 19 20:30:20 2010
@@ -32,7 +32,7 @@ import org.apache.commons.collections.Un
public final class UnmodifiableMapIterator<K, V> implements MapIterator<K, V>,
Unmodifiable {
/** The iterator being decorated */
- private MapIterator<K, V> iterator;
+ private final MapIterator<K, V> iterator;
//-----------------------------------------------------------------------
/**
Modified:
commons/proper/collections/trunk/src/java/org/apache/commons/collections/list/SetUniqueList.java
URL:
http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/list/SetUniqueList.java?rev=956291&r1=956290&r2=956291&view=diff
==============================================================================
---
commons/proper/collections/trunk/src/java/org/apache/commons/collections/list/SetUniqueList.java
(original)
+++
commons/proper/collections/trunk/src/java/org/apache/commons/collections/list/SetUniqueList.java
Sat Jun 19 20:30:20 2010
@@ -286,9 +286,9 @@ public class SetUniqueList<E> extends Ab
@SuppressWarnings("unchecked")
protected Set<E> createSetBasedOnList(Set<E> set, List<E> list) {
- Set<E> subSet = null;
+ Set<E> subSet;
if (set.getClass().equals(HashSet.class)) {
- subSet = new HashSet<E>();
+ subSet = new HashSet<E>(list.size());
} else {
try {
subSet = (Set<E>) set.getClass().newInstance();
Modified:
commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/AbstractReferenceMap.java
URL:
http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/AbstractReferenceMap.java?rev=956291&r1=956290&r2=956291&view=diff
==============================================================================
---
commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/AbstractReferenceMap.java
(original)
+++
commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/AbstractReferenceMap.java
Sat Jun 19 20:30:20 2010
@@ -905,7 +905,7 @@ public abstract class AbstractReferenceM
*/
static class SoftRef<T> extends SoftReference<T> {
/** the hashCode of the key (even if the reference points to a value)
*/
- private int hash;
+ private final int hash;
public SoftRef(int hash, T r, ReferenceQueue<? super T> q) {
super(r, q);
@@ -922,7 +922,7 @@ public abstract class AbstractReferenceM
*/
static class WeakRef<T> extends WeakReference<T> {
/** the hashCode of the key (even if the reference points to a value)
*/
- private int hash;
+ private final int hash;
public WeakRef(int hash, T r, ReferenceQueue<? super T> q) {
super(r, q);