import "copyrightAndOthers.stg"

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

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

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

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

package org.eclipse.collections.impl.set.immutable.primitive;

import org.eclipse.collections.api.<name>Iterable;
import org.eclipse.collections.api.factory.set.primitive.Immutable<name>SetFactory;
import org.eclipse.collections.api.set.primitive.Immutable<name>Set;
import org.eclipse.collections.impl.set.mutable.primitive.<name>HashSet;
import org.eclipse.collections.impl.factory.primitive.<name>Sets;
<(wideStreamImport.(type))>

/**
 * Immutable<name>SetFactoryImpl is a factory implementation which creates instances of type {@link Immutable<name>Set}.
 * This file was automatically generated from template file immutablePrimitiveSetFactoryImpl.stg.
 *
 * @since 4.0.
 */
public enum Immutable<name>SetFactoryImpl implements Immutable<name>SetFactory
{
    INSTANCE;

    @Override
    public Immutable<name>Set empty()
    {
        return Immutable<name>EmptySet.INSTANCE;
    }

    @Override
    public Immutable<name>Set of()
    {
        return this.empty();
    }

    @Override
    public Immutable<name>Set with()
    {
        return this.empty();
    }

    @Override
    public Immutable<name>Set of(<type> one)
    {
        return this.with(one);
    }

    @Override
    public Immutable<name>Set with(<type> one)
    {
        return new Immutable<name>SingletonSet(one);
    }

    @Override
    public Immutable<name>Set of(<type>... items)
    {
        return this.with(items);
    }

    @Override
    public Immutable<name>Set with(<type>... items)
    {
        if (items == null || items.length == 0)
        {
            return this.with();
        }
        if (items.length == 1)
        {
            return this.with(items[0]);
        }
        return <name>HashSet.newSetWith(items).toImmutable();
    }

    @Override
    public Immutable<name>Set ofAll(<name>Iterable items)
    {
        return this.withAll(items);
    }

    @Override
    public Immutable<name>Set withAll(<name>Iterable items)
    {
        if (items instanceof Immutable<name>Set)
        {
            return (Immutable<name>Set) items;
        }
        return this.with(items.toArray());
    }

    /**
     * @since 10.0
     */
    @Override
    public Immutable<name>Set ofAll(Iterable\<<wrapperName>\> iterable)
    {
        return this.withAll(iterable);
    }

    /**
     * @since 10.0
     */
    @Override
    public Immutable<name>Set withAll(Iterable\<<wrapperName>\> iterable)
    {
        return <name>Sets.mutable.withAll(iterable).toImmutable();
    }
    <(streamMethods.(type))()>
}

>>

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

allMethods() ::= <<


/**
 * @since 9.0
 */
@Override
public Immutable<name>Set ofAll(<(wideStream.(type))> items)
{
    return this.withAll(items);
}

/**
 * @since 9.0
 */
@Override
public Immutable<name>Set withAll(<(wideStream.(type))> items)
{
    return this.with(items.toArray());
}
>>

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"
]
