How do I translate one of my functions into an Iterable<T> function?
<p>Im working on a code to implement different search functions to solve the Farmer Wolf Goat Cabbage problem. We were given several classes that our main and FarmerWolfGoatCabbage class implemented. One of the classes, AbstractSolver includes the line</p>

<pre><code>        Iterable&lt;AState&gt; moves = s.getPossibleMoves();
        for (AState move : moves)
            if (!closed.contains(move))
                addState(move);
</code></pre>

<p>Here is my FarmerWolfGoatCabbage class.I basically want to translate the following function</p>

<pre><code>public DepthFirstSolver getPossibleMoves1(){

    DepthFirstSolver moves = null;

    //use getOpposite() and addIfSafe
    FarmerWolfGoatState fwgsParent = new FarmerWolfGoatState();
    FarmerWolfGoatState fwgsChild = null;
    int hash;
    // the farmer's current position before crossing the river
    Side farmerCurrent = this.farmer;

    if(this.wolf == farmerCurrent){
        fwgsChild = new FarmerWolfGoatState(this, this.getOpposite(this.farmer),
                    this.getOpposite(this.wolf), this.goat, this.cabbage);
        hash = fwgsChild.hashCode();
        if(addIfSafe(hash))
            moves.addState(fwgsChild);  
        System.out.println("W");
    }

    if(this.cabbage == farmerCurrent){
        fwgsChild = new FarmerWolfGoatState(this, this.getOpposite(this.farmer),
                    this.wolf, this.goat, this.getOpposite(this.cabbage));
        hash = fwgsChild.hashCode();
        if(addIfSafe(hash))
            moves.addState(fwgsChild);  
        System.out.println("C");
    }   

    if(this.goat == farmerCurrent){
        fwgsChild = new FarmerWolfGoatState(this, this.getOpposite(this.farmer),
                    this.wolf, this.getOpposite(this.goat), this.cabbage);
        hash = fwgsChild.hashCode();
        fwgsChild.getPosition();
        //

        if (fwgsChild == null)
            System.out.println("NULL");

        if(addIfSafe(hash))
            //moves.addState(fwgsChild);
        System.out.println("G");
    }

    return moves;
}
</code></pre>

<p>into a similar function but with the Iterable return type</p>

<pre><code>public Iterable&lt;AState&gt; getPossibleMoves() 
{
}
</code></pre>
