You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by oh...@apache.org on 2014/11/01 21:51:10 UTC

svn commit: r1636040 - /commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/tree/AbstractImmutableNodeHandler.java

Author: oheger
Date: Sat Nov  1 20:51:09 2014
New Revision: 1636040

URL: http://svn.apache.org/r1636040
Log:
Removed duplicate code.

The method for querying children by name can be implemented on top of the
generic getMatchingChildren() method. getChildrenCount() can be handled in a
similar way.

Modified:
    commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/tree/AbstractImmutableNodeHandler.java

Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/tree/AbstractImmutableNodeHandler.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/tree/AbstractImmutableNodeHandler.java?rev=1636040&r1=1636039&r2=1636040&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/tree/AbstractImmutableNodeHandler.java (original)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration2/tree/AbstractImmutableNodeHandler.java Sat Nov  1 20:51:09 2014
@@ -21,8 +21,6 @@ import java.util.Collections;
 import java.util.List;
 import java.util.Set;
 
-import org.apache.commons.lang3.StringUtils;
-
 /**
  * <p>
  * An abstract base class for a {@link NodeHandler} implementation for
@@ -93,16 +91,7 @@ abstract class AbstractImmutableNodeHand
     @Override
     public List<ImmutableNode> getChildren(ImmutableNode node, String name)
     {
-        List<ImmutableNode> result =
-                new ArrayList<ImmutableNode>(node.getChildren().size());
-        for (ImmutableNode c : node.getChildren())
-        {
-            if (StringUtils.equals(name, c.getNodeName()))
-            {
-                result.add(c);
-            }
-        }
-        return Collections.unmodifiableList(result);
+        return getMatchingChildren(node, NodeNameMatchers.EQUALS, name);
     }
 
     @Override
@@ -126,7 +115,7 @@ abstract class AbstractImmutableNodeHand
         }
         else
         {
-            return getChildren(node, name).size();
+            return getMatchingChildrenCount(node, NodeNameMatchers.EQUALS, name);
         }
     }