commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t.@apache.org
Subject svn commit: r1443602 - in /commons/proper/collections/trunk/src/main/java/org/apache/commons/collections: ./ bidimap/ collection/ list/
Date Thu, 07 Feb 2013 17:00:24 GMT
Author: tn
Date: Thu Feb  7 17:00:23 2013
New Revision: 1443602

URL: http://svn.apache.org/viewvc?rev=1443602&view=rev
Log:
[COLLECTIONS-312] Apply remaining changes from patch.

Modified:
    commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/ClosureUtils.java
    commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/CollectionUtils.java
    commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/ExtendedProperties.java
    commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/TransformerUtils.java
    commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bidimap/AbstractDualBidiMap.java
    commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bidimap/DualHashBidiMap.java
    commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/collection/SynchronizedCollection.java
    commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/list/AbstractLinkedList.java
    commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/list/TreeList.java

Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/ClosureUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/ClosureUtils.java?rev=1443602&r1=1443601&r2=1443602&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/ClosureUtils.java
(original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/ClosureUtils.java
Thu Feb  7 17:00:23 2013
@@ -370,15 +370,13 @@ public class ClosureUtils {
      */
     @SuppressWarnings("unchecked")
     public static <E> Closure<E> switchMapClosure(final Map<? extends E, Closure<E>>
objectsAndClosures) {
-        Closure<? super E>[] trs = null;
-        Predicate<E>[] preds = null;
         if (objectsAndClosures == null) {
             throw new IllegalArgumentException("The object and closure map must not be null");
         }
         final Closure<? super E> def = objectsAndClosures.remove(null);
         final int size = objectsAndClosures.size();
-        trs = new Closure[size];
-        preds = new Predicate[size];
+        final Closure<? super E>[] trs = new Closure[size];
+        final Predicate<E>[] preds = new Predicate[size];
         int i = 0;
         for (final Map.Entry<? extends E, Closure<E>> entry : objectsAndClosures.entrySet())
{
             preds[i] = EqualPredicate.<E>equalPredicate(entry.getKey());

Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/CollectionUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/CollectionUtils.java?rev=1443602&r1=1443601&r2=1443602&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/CollectionUtils.java
(original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/CollectionUtils.java
Thu Feb  7 17:00:23 2013
@@ -97,7 +97,8 @@ public class CollectionUtils {
             elements = new HashSet<O>();
             addAll(elements, a);
             addAll(elements, b);
-            newList = new ArrayList<O>();
+            // the resulting list must contain at least each unique element, but may grow
+            newList = new ArrayList<O>(elements.size());
         }
 
         public Iterator<O> iterator() {

Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/ExtendedProperties.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/ExtendedProperties.java?rev=1443602&r1=1443601&r2=1443602&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/ExtendedProperties.java
(original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/ExtendedProperties.java
Thu Feb  7 17:00:23 2013
@@ -1071,7 +1071,7 @@ public class ExtendedProperties extends 
             if (defaults != null) {
                 return defaults.getVector(key, defaultValue);
             } else {
-                return defaultValue == null ? new Vector<String>() : defaultValue;
+                return defaultValue == null ? new Vector<String>(1) : defaultValue;
             }
         } else {
             throw new ClassCastException('\'' + key + "' doesn't map to a Vector object");
@@ -1125,7 +1125,7 @@ public class ExtendedProperties extends 
             if (defaults != null) {
                 return defaults.getList(key, defaultValue);
             } else {
-                return defaultValue == null ? new ArrayList<String>() : defaultValue;
+                return defaultValue == null ? new ArrayList<String>(1) : defaultValue;
             }
         } else {
             throw new ClassCastException('\'' + key + "' doesn't map to a List object");

Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/TransformerUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/TransformerUtils.java?rev=1443602&r1=1443601&r2=1443602&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/TransformerUtils.java
(original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/TransformerUtils.java
Thu Feb  7 17:00:23 2013
@@ -342,15 +342,13 @@ public class TransformerUtils {
     public static <I, O> Transformer<I, O> switchMapTransformer(
             final Map<I, Transformer<I, O>> objectsAndTransformers) {
 
-        Transformer<? super I, ? extends O>[] trs = null;
-        Predicate<I>[] preds = null;
         if (objectsAndTransformers == null) {
             throw new IllegalArgumentException("The object and transformer map must not be
null");
         }
         final Transformer<? super I, ? extends O> def = objectsAndTransformers.remove(null);
         final int size = objectsAndTransformers.size();
-        trs = new Transformer[size];
-        preds = new Predicate[size];
+        final Transformer<? super I, ? extends O>[] trs = new Transformer[size];
+        final Predicate<I>[] preds = new Predicate[size];
         int i = 0;
         for (final Map.Entry<I, Transformer<I, O>> entry : objectsAndTransformers.entrySet())
{
             preds[i] = EqualPredicate.<I>equalPredicate(entry.getKey());

Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bidimap/AbstractDualBidiMap.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bidimap/AbstractDualBidiMap.java?rev=1443602&r1=1443601&r2=1443602&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bidimap/AbstractDualBidiMap.java
(original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bidimap/AbstractDualBidiMap.java
Thu Feb  7 17:00:23 2013
@@ -661,8 +661,7 @@ public abstract class AbstractDualBidiMa
                         "Cannot use setValue() when the object being set is already in the
map");
             }
             parent.put(key, value);
-            final V oldValue = super.setValue(value);
-            return oldValue;
+            return super.setValue(value);
         }
     }
 

Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bidimap/DualHashBidiMap.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bidimap/DualHashBidiMap.java?rev=1443602&r1=1443601&r2=1443602&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bidimap/DualHashBidiMap.java
(original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bidimap/DualHashBidiMap.java
Thu Feb  7 17:00:23 2013
@@ -100,8 +100,7 @@ public class DualHashBidiMap<K, V> exten
         normalMap = new HashMap<K, V>();
         reverseMap = new HashMap<V, K>();
         @SuppressWarnings("unchecked") // will fail at runtime if stream is incorrect
-        final
-        Map<K, V> map = (Map<K, V>) in.readObject();
+        final Map<K, V> map = (Map<K, V>) in.readObject();
         putAll(map);
     }
 

Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/collection/SynchronizedCollection.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/collection/SynchronizedCollection.java?rev=1443602&r1=1443601&r2=1443602&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/collection/SynchronizedCollection.java
(original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/collection/SynchronizedCollection.java
Thu Feb  7 17:00:23 2013
@@ -193,7 +193,7 @@ public class SynchronizedCollection<E> i
             if (object == this) {
                 return true;
             }
-            return decorated().equals(object);
+            return object == this || decorated().equals(object);
         }
     }
 

Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/list/AbstractLinkedList.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/list/AbstractLinkedList.java?rev=1443602&r1=1443601&r2=1443602&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/list/AbstractLinkedList.java
(original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/list/AbstractLinkedList.java
Thu Feb  7 17:00:23 2013
@@ -386,7 +386,7 @@ public abstract class AbstractLinkedList
             return "[]";
         }
         final StringBuilder buf = new StringBuilder(16 * size());
-        buf.append("[");
+        buf.append('[');
 
         final Iterator<E> it = iterator();
         boolean hasNext = it.hasNext();
@@ -398,7 +398,7 @@ public abstract class AbstractLinkedList
                 buf.append(", ");
             }
         }
-        buf.append("]");
+        buf.append(']');
         return buf.toString();
     }
 

Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/list/TreeList.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/list/TreeList.java?rev=1443602&r1=1443601&r2=1443602&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/list/TreeList.java
(original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/list/TreeList.java
Thu Feb  7 17:00:23 2013
@@ -420,8 +420,6 @@ public class TreeList<E> extends Abstrac
         }
 
         private AVLNode<E> insertOnLeft(final int indexRelativeToMe, final E obj) {
-            AVLNode<E> ret = this;
-
             if (getLeftSubTree() == null) {
                 setLeft(new AVLNode<E>(-1, obj, this, left), null);
             } else {
@@ -431,14 +429,12 @@ public class TreeList<E> extends Abstrac
             if (relativePosition >= 0) {
                 relativePosition++;
             }
-            ret = balance();
+            AVLNode<E> ret = balance();
             recalcHeight();
             return ret;
         }
 
         private AVLNode<E> insertOnRight(final int indexRelativeToMe, final E obj)
{
-            AVLNode<E> ret = this;
-
             if (getRightSubTree() == null) {
                 setRight(new AVLNode<E>(+1, obj, right, this), null);
             } else {
@@ -447,7 +443,7 @@ public class TreeList<E> extends Abstrac
             if (relativePosition < 0) {
                 relativePosition--;
             }
-            ret = balance();
+            AVLNode<E> ret = balance();
             recalcHeight();
             return ret;
         }
@@ -777,8 +773,19 @@ public class TreeList<E> extends Abstrac
          */
         @Override
         public String toString() {
-            return "AVLNode(" + relativePosition + "," + (left != null) + "," + value +
-                "," + (getRightSubTree() != null) + ", faedelung " + rightIsNext + " )";
+            return new StringBuilder()
+                .append("AVLNode(")
+                .append(relativePosition)
+                .append(',')
+                .append(left != null)
+                .append(',')
+                .append(value)
+                .append(',')
+                .append(getRightSubTree() != null)
+                .append(", faedelung ")
+                .append(rightIsNext)
+                .append(" )")
+                .toString();
         }
     }
 



Mime
View raw message