import "copyrightAndOthers.stg"
import "primitiveAPI.stg"

targetPath() ::= "org/eclipse/collections/api/list/primitive"

fileName(primitive) ::= "Immutable<primitive.name>List"

class(primitive) ::= <<
<body(primitive.type, primitive.name)>
>>

body(type, name) ::= <<
<copyrightAndOthers()>

package org.eclipse.collections.api.list.primitive;

import org.eclipse.collections.api.<name>Iterable;
import org.eclipse.collections.api.block.function.primitive.<name>IntToObjectFunction;
import org.eclipse.collections.api.block.function.primitive.<name>ToObjectFunction;
import org.eclipse.collections.api.block.predicate.primitive.<name>Predicate;
import org.eclipse.collections.api.block.procedure.primitive.<name>Procedure;
import org.eclipse.collections.api.collection.primitive.Immutable<name>Collection;
import org.eclipse.collections.api.list.ImmutableList;
import org.eclipse.collections.api.tuple.primitive.<name><name>Pair;
import org.eclipse.collections.api.tuple.primitive.<name>ObjectPair;

/**
 * This file was automatically generated from template file immutablePrimitiveList.stg.
 *
 * @since 3.0.
 */
public interface Immutable<name>List extends Immutable<name>Collection, <name>List
{
    <sharedAPI(fileName(primitive), name)>

    /**
     * @since 9.0.
     */
    @Override
    default Immutable<name>List tap(<name>Procedure procedure)
    {
        this.forEach(procedure);
        return this;
    }

    @Override
    \<V> ImmutableList\<V> collect(<name>ToObjectFunction\<? extends V> function);

    /**
     * Returns a new ImmutableList using results obtained by applying the specified function to each element
     * and its corresponding index.
     *
     * @since 9.1.
     */
    @Override
    default \<V> ImmutableList\<V> collectWithIndex(<name>IntToObjectFunction\<? extends V> function)
    {
        int[] index = {0};
        return this.collect(each -> function.value(each, index[0]++));
    }

    <immutableAPI(fileName(primitive), type, name)>

    @Override
    Immutable<name>List toReversed();

    /**
     * @since 6.0.
     */
    @Override
    Immutable<name>List distinct();

    @Override
    Immutable<name>List subList(int fromIndex, int toIndex);

    /**
     * Returns an {@code ImmutableList} formed from this {@code Immutable<name>List} and another {@code <name>List} by
     * combining corresponding elements in pairs. If one of the two {@code <name>List}s is longer than the other, its
     * remaining elements are ignored.
     *
     * @since 9.1.
     */
    default ImmutableList\<<name><name>Pair> zip<name>(<name>Iterable iterable)
    {
        throw new UnsupportedOperationException("Default method to prevent breaking backwards compatibility");
    }

    /**
     * Returns an {@code ImmutableList} formed from this {@code Immutable<name>List} and a {@code ListIterable} by
     * combining corresponding elements in pairs. If one of the two Lists is longer than the other, its
     * remaining elements are ignored.
     *
     * @since 9.1.
     */
    default \<T> ImmutableList\<<name>ObjectPair\<T\>> zip(Iterable\<T> iterable)
    {
        throw new UnsupportedOperationException("Default method to prevent breaking backwards compatibility");
    }
}

>>
