import "copyrightAndOthers.stg"

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

fileName(primitive) ::= "Mutable<primitive.name>ListFactory"

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

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

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

import org.eclipse.collections.api.<name>Iterable;
import org.eclipse.collections.api.list.primitive.Mutable<name>List;
<(wideStreamImport.(type))>

/**
 * A factory which creates instances of type {@link Mutable<name>List}.
 * This file was automatically generated from template file mutablePrimitiveListFactory.stg.
 *
 * @since 6.0.
 */
public interface Mutable<name>ListFactory
{
    Mutable<name>List empty();

    /**
     * Same as {@link #empty()}.
     */
    Mutable<name>List of();

    /**
     * Same as {@link #empty()}.
     */
    Mutable<name>List with();

    /**
     * Same as {@link #empty()}. but takes in an initial capacity
     * @since 10.3
     */
    default Mutable<name>List withInitialCapacity(int capacity)
    {
        throw new UnsupportedOperationException("Default method to ensure backwards compatibility");
    }

    /**
     * Same as {@link #with(<type>[])}.
     */
    Mutable<name>List of(<type>... items);

    /**
     * Creates a new list using the passed {@code items} argument as the backing store.
     * \<p>
     * !!! WARNING: This method uses the passed in array, so can be very unsafe if the original
     * array is held onto anywhere else. !!!
     */
    Mutable<name>List with(<type>... items);

    /**
     * Creates a new list by first copying the array passed in.
     */
    default Mutable<name>List wrapCopy(<type>... array)
    {
        <type>[] newArray = new <type>[array.length];
        System.arraycopy(array, 0, newArray, 0, array.length);
        return this.with(newArray);
    }

    /**
     * Same as {@link #withAll(<name>Iterable)}.
     */
    Mutable<name>List ofAll(<name>Iterable items);

    Mutable<name>List withAll(<name>Iterable items);

    /**
     * Same as {@link #withAll(Iterable)}.
     */
    Mutable<name>List ofAll(Iterable\<<wrapperName>\> iterable);

    Mutable<name>List withAll(Iterable\<<wrapperName>\> iterable);
    <(streamMethods.(type))()>
}

>>

streamMethods ::= [
    "byte": "noMethods",
    "short": "noMethods",
    "char": "noMethods",
    "int": "allMethods",
    "long": "allMethods",
    "float": "noMethods",
    "double": "allMethods",
    "boolean": "noMethods"
    ]

allMethods() ::= <<


/**
 * @since 9.0
 */
Mutable<name>List ofAll(<(wideStream.(type))> items);

/**
 * @since 9.0
 */
Mutable<name>List withAll(<(wideStream.(type))> items);
>>

noMethods() ::= ""

wideStream ::= [
    "int": "IntStream",
    "long": "LongStream",
    "double": "DoubleStream",
    default: "no matching wide type"
]

wideStreamImport ::= [
    "boolean": "",
    "byte": "",
    "short": "",
    "char": "",
    "int": "import java.util.stream.IntStream;",
    "long": "import java.util.stream.LongStream;",
    "float": "",
    "double": "import java.util.stream.DoubleStream;",
    default: "no matching wide type"
]
