package de.jangobrick.swapper;

import java.awt.Container;
import java.awt.LayoutManager;


/**
 * Abstract extension of the {@link Swap} class for {@code Container}
 * components.
 * 
 * @param <C> The wrapped component type.
 */
public abstract class ContainerSwap<C extends Container> extends Swap<C>
{
    /**
     * Sets the component's {@link LayoutManager} to the one given.
     * 
     * @param layout The new layout manager to use.
     * 
     * @return This instance.
     */
    public ContainerSwap<C> layout(LayoutManager layout)
    {
        getComponent().setLayout(layout);
        return this;
    }

    /**
     * Adds the given {@link Swap} as a child to this Swap's component.
     * 
     * @param swap The Swap to add as a child.
     * 
     * @return This instance.
     */
    public ContainerSwap<C> add(Swap<?> swap)
    {
        getComponent().add(swap.getComponent());
        return this;
    }

    /**
     * Adds the given {@link Swap} as a child to this Swap's component, using
     * the given constraints object.
     * 
     * @param swap The Swap to add as a child.
     * @param constraints The constraints object to use.
     * 
     * @return This instance.
     */
    public ContainerSwap<C> add(Swap<?> swap, Object constraints)
    {
        getComponent().add(swap.getComponent(), constraints);
        return this;
    }
}

@@ -83,16 +83,94 @@
 anager;%0A
+import java.util.ArrayList;%0Aimport java.util.Iterator;%0Aimport java.util.List;%0A
 %0A%0A/**%0A *
@@ -375,17 +375,113 @@
 Swap%3CC%3E%0A
-%7B
+        implements Iterable%3CSwap%3C?%3E%3E%0A%7B%0A    private List%3CSwap%3C?%3E%3E components = new ArrayList%3C%3E();%0A
 %0A    /**
@@ -780,32 +780,426 @@
 rn this;%0A    %7D%0A%0A
+    /**%0A     * @return The number of children this container has.%0A     */%0A    public int count()%0A    %7B%0A        return components.size();%0A    %7D%0A%0A    /**%0A     * Obtains the child %7B@link Swap%7D at the given index.%0A     * %0A     * @param index The index.%0A     * %0A     * @return The Swap at the given index.%0A     */%0A    public Swap%3C?%3E get(int index)%0A    %7B%0A        return components.get(index);%0A    %7D%0A%0A
     /**%0A     * A
@@ -1407,32 +1407,62 @@
 %3C?%3E swap)%0A    %7B%0A
+        components.add(swap);%0A
         getCompo
@@ -1494,16 +1494,17 @@
 ent());%0A
+%0A
         
@@ -1868,32 +1868,62 @@
 straints)%0A    %7B%0A
+        components.add(swap);%0A
         getCompo
@@ -1968,16 +1968,17 @@
 aints);%0A
+%0A
         
@@ -1995,11 +1995,933 @@
 s;%0A    %7D
+%0A%0A    /**%0A     * Removes the %7B@link Swap%7D at the given index from this Swap's child list.%0A     * %0A     * @param index The index of the Swap to remove.%0A     * %0A     * @return This instance.%0A     */%0A    public ContainerSwap%3CC%3E remove(int index)%0A    %7B%0A        components.remove(index);%0A        getComponent().remove(index);%0A%0A        return this;%0A    %7D%0A%0A    /**%0A     * Removes the given %7B@link Swap%7D from this Swap's child list.%0A     * %0A     * @param swap The swap to remove.%0A     * %0A     * @return This instance.%0A     */%0A    public ContainerSwap%3CC%3E remove(Swap%3C?%3E swap)%0A    %7B%0A        components.remove(swap);%0A        getComponent().remove(swap.getComponent());%0A%0A        return this;%0A    %7D%0A%0A    /**%0A     * Returns an iterator over this %7B@link Swap%7D's children.%0A     * %0A     * @return An iterator over the children.%0A     */%0A    @Override%0A    public Iterator%3CSwap%3C?%3E%3E iterator()%0A    %7B%0A        return components.iterator();%0A    %7D
 %0A%7D%0A

Add more children-focused methods to ContainerSwap