/*
 * [TestIterable.java]
 *
 * Summary: example use of Iterable.
 *
 * Copyright: (c) 2009-2017 Roedy Green, Canadian Mind Products, http://mindprod.com
 *
 * Licence: This software may be copied and used freely for any purpose but military.
 *          http://mindprod.com/contact/nonmil.html
 *
 * Requires: JDK 1.8+
 *
 * Created with: JetBrains IntelliJ IDEA IDE http://www.jetbrains.com/idea/
 *
 * Version History:
 *  1.0 2009-01-01 initial version
 */
package com.mindprod.example;

import java.util.ArrayList;
import java.util.Iterator;

import static java.lang.System.*;

/**
 * example use of Iterable.
 *
 * @author Roedy Green, Canadian Mind Products
 * @version 1.0 2009-01-01 initial version
 * @since 2009-01-01
 */
public final class TestIterable implements Iterable<String>
    {
    /**
     * internal ArrayList of seed varieties
     */
    private final ArrayList<String> a = new ArrayList<>( 10 );

    {
    // init when TestIterable object instantiated.
    a.add( "pinecone" );
    a.add( "apple seed" );
    a.add( "peach pit" );
    a.add( "cocoanut" );
    a.add( "acorn" );
    }

    /**
     * Sample code to TestIterable. Needs JDK 1.8+
     *
     * @param args not used
     */
    public static void main( String[] args )
        {
        TestIterable t = new TestIterable();
        for ( String s : t )
            {
            out.println( s );
            }
        } // end main

    /**
     * iterator for entire class, just iterates over internal arrayList
     *
     * @return Iterator over entire class
     */
    public Iterator<String> iterator()
        {
        return a.iterator();
        }
    }