import "copyrightAndOthers.stg"
import "primitiveEquals.stg"
import "primitiveHashCode.stg"
import "primitiveLiteral.stg"

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

fileName(primitive) ::= "Unmodifiable<primitive.name>Stack"

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

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

package org.eclipse.collections.impl.stack.mutable.primitive;

import java.io.Serializable;
import java.util.Collection;
import java.util.Objects;

import org.eclipse.collections.api.<name>Iterable;
import org.eclipse.collections.api.Lazy<name>Iterable;
import org.eclipse.collections.api.RichIterable;
import org.eclipse.collections.api.bag.primitive.Mutable<name>Bag;
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.function.primitive.Object<name>ToObjectFunction;
import org.eclipse.collections.api.block.function.primitive.Object<name>IntToObjectFunction;
import org.eclipse.collections.api.block.predicate.primitive.<name>Predicate;
import org.eclipse.collections.api.block.procedure.primitive.<name>IntProcedure;
import org.eclipse.collections.api.block.procedure.primitive.<name>Procedure;
import org.eclipse.collections.api.iterator.<name>Iterator;
import org.eclipse.collections.api.list.primitive.<name>List;
import org.eclipse.collections.api.list.primitive.Mutable<name>List;
import org.eclipse.collections.api.set.primitive.Mutable<name>Set;
import org.eclipse.collections.api.stack.MutableStack;
import org.eclipse.collections.api.stack.primitive.Immutable<name>Stack;
import org.eclipse.collections.api.stack.primitive.Mutable<name>Stack;
import org.eclipse.collections.impl.factory.primitive.<name>Stacks;
import org.eclipse.collections.impl.iterator.Unmodifiable<name>Iterator;
import org.eclipse.collections.impl.lazy.primitive.Lazy<name>IterableAdapter;

/**
 * This file was automatically generated from template file unmodifiablePrimitiveStack.stg.
 *
 * @since 3.1.
 */
public class Unmodifiable<name>Stack
        implements Mutable<name>Stack, Serializable
{
    private static final long serialVersionUID = 1L;

    private final Mutable<name>Stack stack;

    public Unmodifiable<name>Stack(Mutable<name>Stack stack)
    {
        this.stack = Objects.requireNonNull(stack);
    }

    @Override
    public void push(<type> item)
    {
        throw new UnsupportedOperationException("Cannot call push() on " + this.getClass().getSimpleName());
    }

    @Override
    public <type> pop()
    {
        throw new UnsupportedOperationException("Cannot call pop() on " + this.getClass().getSimpleName());
    }

    @Override
    public <name>List pop(int count)
    {
        throw new UnsupportedOperationException("Cannot call pop() on " + this.getClass().getSimpleName());
    }

    @Override
    public <type> peek()
    {
        return this.stack.peek();
    }

    @Override
    public <name>List peek(int count)
    {
        return this.stack.peek(count);
    }

    @Override
    public <type> peekAt(int index)
    {
        return this.stack.peekAt(index);
    }

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

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

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

    @Override
    public void clear()
    {
        throw new UnsupportedOperationException("Cannot call clear() on " + this.getClass().getSimpleName());
    }

    @Override
    public boolean contains(<type> value)
    {
        return this.stack.contains(value);
    }

    @Override
    public boolean containsAll(<type>... source)
    {
        return this.stack.containsAll(source);
    }

    @Override
    public boolean containsAll(<name>Iterable source)
    {
        return this.stack.containsAll(source);
    }

    @Override
    public <name>Iterator <type>Iterator()
    {
        return new Unmodifiable<name>Iterator(this.stack.<type>Iterator());
    }

    /**
     * @since 7.0.
     */
    @Override
    public void each(<name>Procedure procedure)
    {
        this.stack.forEach(procedure);
    }

    @Override
    public int count(<name>Predicate predicate)
    {
        return this.stack.count(predicate);
    }

    @Override
    public boolean anySatisfy(<name>Predicate predicate)
    {
        return this.stack.anySatisfy(predicate);
    }

    @Override
    public boolean allSatisfy(<name>Predicate predicate)
    {
        return this.stack.allSatisfy(predicate);
    }

    @Override
    public boolean noneSatisfy(<name>Predicate predicate)
    {
        return this.stack.noneSatisfy(predicate);
    }

    @Override
    public <type> detectIfNone(<name>Predicate predicate, <type> ifNone)
    {
        return this.stack.detectIfNone(predicate, ifNone);
    }

    @Override
    public Mutable<name>Stack select(<name>Predicate predicate)
    {
        return this.stack.select(predicate);
    }

    @Override
    public Mutable<name>Stack reject(<name>Predicate predicate)
    {
        return this.stack.reject(predicate);
    }

    @Override
    public \<V> MutableStack\<V> collect(<name>ToObjectFunction\<? extends V> function)
    {
        return this.stack.collect(function);
    }

    <(arithmeticMethods.(type))(name, type)>
    @Override
    public <type>[] toArray()
    {
        return this.stack.toArray();
    }

    @Override
    public <type>[] toArray(<type>[] target)
    {
        return this.stack.toArray(target);
    }

    @Override
    public String toString()
    {
        return this.stack.toString();
    }

    @Override
    public String makeString()
    {
        return this.stack.makeString();
    }

    @Override
    public String makeString(String separator)
    {
        return this.stack.makeString(separator);
    }

    @Override
    public String makeString(String start, String separator, String end)
    {
        return this.stack.makeString(start, separator, end);
    }

    @Override
    public void appendString(Appendable appendable)
    {
        this.stack.appendString(appendable);
    }

    @Override
    public void appendString(Appendable appendable, String separator)
    {
        this.stack.appendString(appendable, separator);
    }

    @Override
    public void appendString(
            Appendable appendable,
            String start,
            String separator,
            String end)
    {
        this.stack.appendString(appendable, start, separator, end);
    }

    @Override
    public Mutable<name>List toList()
    {
        return this.stack.toList();
    }

    @Override
    public Mutable<name>Set toSet()
    {
        return this.stack.toSet();
    }

    @Override
    public Mutable<name>Bag toBag()
    {
        return this.stack.toBag();
    }

    @Override
    public boolean equals(Object otherStack)
    {
        return this.stack.equals(otherStack);
    }

    @Override
    public int hashCode()
    {
        return this.stack.hashCode();
    }

    @Override
    public Lazy<name>Iterable asLazy()
    {
        return new Lazy<name>IterableAdapter(this);
    }

    @Override
    public Mutable<name>Stack asUnmodifiable()
    {
        return this;
    }

    @Override
    public Mutable<name>Stack asSynchronized()
    {
        return new Synchronized<name>Stack(this);
    }

    @Override
    public Immutable<name>Stack toImmutable()
    {
        return <name>Stacks.immutable.withAllReversed(this);
    }

    /**
     * @since 9.2.
     */
    @Override
    public Mutable<name>Stack newEmpty()
    {
        return this.stack.newEmpty();
    }

    @Override
    public \<T> T injectInto(T injectedValue, Object<name>ToObjectFunction\<? super T, ? extends T> function)
    {
        return this.stack.injectInto(injectedValue, function);
    }

    @Override
    public RichIterable\<<name>Iterable> chunk(int size)
    {
        return this.stack.chunk(size);
    }

    @Override
    public <type> getFirst()
    {
        return this.stack.getFirst();
    }

    @Override
    public int indexOf(<type> value)
    {
        return this.stack.indexOf(value);
    }

    @Override
    public \<T> T injectIntoWithIndex(T injectedValue, Object<name>IntToObjectFunction\<? super T, ? extends T> function)
    {
        return this.stack.injectIntoWithIndex(injectedValue, function);
    }

    @Override
    public void forEachWithIndex(<name>IntProcedure procedure)
    {
        this.stack.forEachWithIndex(procedure);
    }

    /**
     * Returns a new MutableStack using results obtained by applying the specified function to each element
     * and its corresponding index.
     *
     * @since 9.1.
     */
    @Override
    public \<V> MutableStack\<V> collectWithIndex(<name>IntToObjectFunction\<? extends V> function)
    {
        return this.stack.collectWithIndex(function);
    }

    /**
     * Adds elements to the target Collection using results obtained by applying the specified function to each element
     * and its corresponding index.
     *
     * @since 9.1.
     */
    @Override
    public \<V, R extends Collection\<V\>> R collectWithIndex(<name>IntToObjectFunction\<? extends V> function, R target)
    {
        return this.stack.collectWithIndex(function, target);
    }
}

>>

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

allMethods(name, type) ::=<<
@Override
public <wideType.(type)> sum()
{
    return this.stack.sum();
}

@Override
public <type> max()
{
    return this.stack.max();
}

@Override
public <type> min()
{
    return this.stack.min();
}

@Override
public <type> minIfEmpty(<type> defaultValue)
{
    return this.stack.minIfEmpty(defaultValue);
}

@Override
public <type> maxIfEmpty(<type> defaultValue)
{
    return this.stack.maxIfEmpty(defaultValue);
}

@Override
public double average()
{
    return this.stack.average();
}

@Override
public double median()
{
    return this.stack.median();
}

@Override
public Mutable<name>List toSortedList()
{
    return this.stack.toSortedList();
}

@Override
public <type>[] toSortedArray()
{
    return this.stack.toSortedArray();
}

>>

noMethods(name, type) ::= ""
