WICKET-6004 Wicket 8 cleanup - remove deprecated methods in MarkupContainer 
relating to hierarchy iterator and indices


Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/e1741df3
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/e1741df3
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/e1741df3

Branch: refs/heads/lambdas
Commit: e1741df37fea65c0e920eab4e4b70b6d7d4e669d
Parents: 32f1eff
Author: Sven Meier <[email protected]>
Authored: Mon Oct 19 14:22:26 2015 +0200
Committer: Sven Meier <[email protected]>
Committed: Mon Oct 19 14:45:11 2015 +0200

----------------------------------------------------------------------
 .../java/org/apache/wicket/MarkupContainer.java | 107 -------------------
 .../org/apache/wicket/MarkupContainerTest.java  |  91 ----------------
 2 files changed, 198 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/e1741df3/wicket-core/src/main/java/org/apache/wicket/MarkupContainer.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/MarkupContainer.java 
b/wicket-core/src/main/java/org/apache/wicket/MarkupContainer.java
index b739d47..0c04a54 100644
--- a/wicket-core/src/main/java/org/apache/wicket/MarkupContainer.java
+++ b/wicket-core/src/main/java/org/apache/wicket/MarkupContainer.java
@@ -23,7 +23,6 @@ import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.NoSuchElementException;
 
 import org.apache.wicket.core.util.string.ComponentStrings;
 import org.apache.wicket.markup.ComponentTag;
@@ -42,7 +41,6 @@ import org.apache.wicket.model.IComponentInheritedModel;
 import org.apache.wicket.model.IModel;
 import org.apache.wicket.model.IWrapModel;
 import org.apache.wicket.settings.DebugSettings;
-import org.apache.wicket.util.iterator.ComponentHierarchyIterator;
 import org.apache.wicket.util.lang.Args;
 import org.apache.wicket.util.lang.Classes;
 import org.apache.wicket.util.lang.Generics;
@@ -892,31 +890,6 @@ public abstract class MarkupContainer extends Component 
implements Iterable<Comp
        }
 
        /**
-        * @return A iterator which iterators over all children and 
grand-children the Component
-        * @deprecated ComponentHierarchyIterator is deprecated.
-        *      Use {@link 
#visitChildren(org.apache.wicket.util.visit.IVisitor)} instead
-        */
-       @Deprecated
-       public final ComponentHierarchyIterator visitChildren()
-       {
-               return new ComponentHierarchyIterator(this);
-       }
-
-       /**
-        * @param clazz
-        *            Filter condition
-        * @return A iterator which iterators over all children and 
grand-children the Component,
-        *         returning only components which implement (instanceof) the 
provided clazz.
-        * @deprecated ComponentHierarchyIterator is deprecated.
-        *      Use {@link #visitChildren(Class, 
org.apache.wicket.util.visit.IVisitor)} instead.
-        */
-       @Deprecated
-       public final ComponentHierarchyIterator visitChildren(final Class<?> 
clazz)
-       {
-               return new 
ComponentHierarchyIterator(this).filterByClass(clazz);
-       }
-
-       /**
         * @param child
         *            Component being added
         */
@@ -1003,35 +976,6 @@ public abstract class MarkupContainer extends Component 
implements Iterable<Comp
        }
 
        /**
-        * Returns child component at the specified index. Note that this 
method has O(n) complexity on
-        * the number of children.
-        * 
-        * @param index
-        *            the index of the child in this container
-        * @throws ArrayIndexOutOfBoundsException
-        *             when {@code index} exceeds {@code size()}
-        * @return child component at the specified index
-        * @deprecated this method is marked for deletion for WICKET8
-        */
-       @Deprecated
-       public final Component get(int index)
-       {
-               final int requestedIndex = index;
-               Component childAtIndex = null;
-               Iterator<Component> childIterator = iterator();
-               while (index >= 0 && childIterator.hasNext())
-               {
-                       childAtIndex = childIterator.next();
-                       index--;
-               }
-               if(index >= 0 || childAtIndex == null)
-               {
-                       throw new 
ArrayIndexOutOfBoundsException(Integer.toString(requestedIndex));
-               }
-               return childAtIndex;
-       }
-
-       /**
         * 
         * @param id
         * @return The child component
@@ -1622,57 +1566,6 @@ public abstract class MarkupContainer extends Component 
implements Iterable<Comp
                super.onAfterRenderChildren();
        }
 
-       /**
-        * Swaps position of children. This method is particularly useful for 
adjusting positions of
-        * repeater's items without rebuilding the component hierarchy
-        * 
-        * @param idx1
-        *            index of first component to be swapped
-        * @param idx2
-        *            index of second component to be swapped
-        * @deprecated this method is marked for deletion for WICKET8
-        */
-       @Deprecated
-       public final void swap(int idx1, int idx2)
-       {
-               int size = children_size();
-               if (idx1 < 0 || idx1 >= size)
-               {
-                       throw new IndexOutOfBoundsException(
-                               "Argument idx is out of bounds: " + idx1 + 
"<>[0," + size + ")");
-               }
-
-               if (idx2 < 0 || idx2 >= size)
-               {
-                       throw new IndexOutOfBoundsException(
-                               "Argument idx is out of bounds: " + idx2 + 
"<>[0," + size + ")");
-               }
-
-               if (idx1 == idx2)
-               {
-                       return;
-               }
-
-               if (children instanceof List)
-               {
-                       @SuppressWarnings("unchecked")
-                       List<Component> childrenList = 
(List<Component>)children;
-                       childrenList.set(idx1, childrenList.set(idx2, 
childrenList.get(idx1)));
-               }
-               else
-               {
-                       @SuppressWarnings("unchecked")
-                       Map<String, Component> childrenMap = (Map<String, 
Component>)children;
-                       List<Component> childrenList = copyChildren();
-                       childrenList.set(idx1, childrenList.set(idx2, 
childrenList.get(idx1)));
-                       childrenMap.clear();
-                       for (Component child : childrenList)
-                       {
-                               childrenMap.put(child.getId(), child);
-                       }
-               }
-       }
-
        @Override
        protected void onDetach()
        {

http://git-wip-us.apache.org/repos/asf/wicket/blob/e1741df3/wicket-core/src/test/java/org/apache/wicket/MarkupContainerTest.java
----------------------------------------------------------------------
diff --git 
a/wicket-core/src/test/java/org/apache/wicket/MarkupContainerTest.java 
b/wicket-core/src/test/java/org/apache/wicket/MarkupContainerTest.java
index 1a5698e..4c24c02 100644
--- a/wicket-core/src/test/java/org/apache/wicket/MarkupContainerTest.java
+++ b/wicket-core/src/test/java/org/apache/wicket/MarkupContainerTest.java
@@ -16,8 +16,6 @@
  */
 package org.apache.wicket;
 
-import static org.hamcrest.CoreMatchers.is;
-
 import org.apache.wicket.markup.IMarkupResourceStreamProvider;
 import org.apache.wicket.markup.html.WebComponent;
 import org.apache.wicket.markup.html.WebMarkupContainer;
@@ -111,95 +109,6 @@ public class MarkupContainerTest extends WicketTestCase
        }
 
        /**
-        * Tests the get(int) method of MarkupContainer.
-        */
-       @Test
-       public void getIndexed() 
-       {
-               MarkupContainer c = new WebMarkupContainer("parent");
-               Component c1 = new WebComponent("c1");
-               Component c2 = new WebComponent("c2");
-
-               c.add(c1);
-               c.add(c2);
-
-               assertThat(c.get(0), is(c1));
-               assertThat(c.get(1), is(c2));
-       }
-
-       /**
-        * Tests the get(int) method of MarkupContainer with non-existing index.
-        */
-       @Test(expected = ArrayIndexOutOfBoundsException.class)
-       public void getIndexedOutOfBounds()
-       {
-               MarkupContainer c = new WebMarkupContainer("parent");
-               Component c1 = new WebComponent("c1");
-
-               c.add(c1);
-
-               assertThat(c.get(0), is(c1));
-               c.get(1);
-       }
-
-       /**
-        * Tests the get(int) method of MarkupContainer with negative index.
-        */
-       @Test(expected = ArrayIndexOutOfBoundsException.class)
-       public void getIndexedNegative()
-       {
-               MarkupContainer c = new WebMarkupContainer("parent");
-               Component c1 = new WebComponent("c1");
-
-               c.add(c1);
-
-               assertThat(c.get(0), is(c1));
-               c.get(-1);
-       }
-
-       /**
-        * Tests the get(int) method of MarkupContainer when the index exceeds 
the number of children.
-        */
-       @Test(expected = ArrayIndexOutOfBoundsException.class)
-       public void getIndexedArrayIndexOutOfBoundsException() 
-       {
-               MarkupContainer c = new WebMarkupContainer("parent");
-               c.get(0);
-       }
-
-       /**
-        * Tests the swap method.
-        */
-       @Test
-       public void swap() 
-       {
-               MarkupContainer c = new WebMarkupContainer("parent");
-               Component c1 = new WebComponent("c1");
-               Component c2 = new WebComponent("c2");
-               Component c3 = new WebComponent("c3");
-
-               c.add(c1);
-               c.add(c2);
-               c.add(c3);
-
-               assertThat(c.get(0), is(c1));
-               assertThat(c.get(1), is(c2));
-               assertThat(c.get(2), is(c3));
-
-               c.swap(0, 1);
-               
-               assertThat(c.get(0), is(c2));
-               assertThat(c.get(1), is(c1));
-               assertThat(c.get(2), is(c3));
-
-               c.swap(0, 2);
-
-               assertThat(c.get(0), is(c3));
-               assertThat(c.get(1), is(c1));
-               assertThat(c.get(2), is(c2));
-       }
-
-       /**
         * https://issues.apache.org/jira/browse/WICKET-4006
         */
        @Test(expected = IllegalArgumentException.class)

Reply via email to