import "copyright.stg"
import "primitiveEquals.stg"
import "primitiveHashCode.stg"
import "primitiveLiteral.stg"

targetPath() ::= "org/eclipse/collections/impl/lazy/primitive"

hasTwoPrimitives() ::= "true"

skipBoolean() ::= "false"

fileName(primitive1, primitive2, sameTwoPrimitives) ::= "Collect<primitive1.name>To<primitive2.name>Iterable"

class(primitive1, primitive2, sameTwoPrimitives) ::= <<
<body(primitive1.type, primitive2.type, primitive1.name, primitive2.name, sameTwoPrimitives)>
>>

body(type1, type2, name1, name2, sameTwoPrimitives) ::= <<
<copyright()>

package org.eclipse.collections.impl.lazy.primitive;

import org.eclipse.collections.api.<name1>Iterable;
import org.eclipse.collections.api.block.function.primitive.<name1>To<name2>Function;
import org.eclipse.collections.api.block.procedure.primitive.<name2>Procedure;
import org.eclipse.collections.api.iterator.<name1>Iterator;
<if(!sameTwoPrimitives)>import org.eclipse.collections.api.iterator.<name2>Iterator;<endif>

/**
 * This file was automatically generated from template file collectPrimitiveToPrimitiveIterable.stg.
 */
public class Collect<name1>To<name2>Iterable
        extends AbstractLazy<name2>Iterable
{
    private final <name1>Iterable iterable;
    private final <name1>To<name2>Function function;

    public Collect<name1>To<name2>Iterable(<name1>Iterable iterable, <name1>To<name2>Function function)
    {
        this.iterable = iterable;
        this.function = function;
    }

    @Override
    public void each(final <name2>Procedure procedure)
    {
        this.iterable.forEach((<type1> each) -> procedure.value(this.function.valueOf(each)));
    }

    @Override
    public <name2>Iterator <type2>Iterator()
    {
        return new <name2>Iterator()
        {
            private final <name1>Iterator iterator = Collect<name1>To<name2>Iterable.this.iterable.<type1>Iterator();

            @Override
            public boolean hasNext()
            {
                return this.iterator.hasNext();
            }

            @Override
            public <type2> next()
            {
                return Collect<name1>To<name2>Iterable.this.function.valueOf(this.iterator.next());
            }
        };
    }

    @Override
    public int size()
    {
        return this.iterable.size();
    }

    @Override
    public boolean isEmpty()
    {
        return this.iterable.isEmpty();
    }

    @Override
    public boolean notEmpty()
    {
        return this.iterable.notEmpty();
    }
}

>>
