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

hasTwoPrimitives() ::= "true"

skipBooleanKeys() ::= "true"

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

fileName(primitive1, primitive2, sameTwoPrimitives) ::= "Unmodifiable<primitive1.name><primitive2.name>Map"

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

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

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

import java.io.Serializable;

import org.eclipse.collections.api.<name2>Iterable;
<if(!sameTwoPrimitives)>import org.eclipse.collections.api.<name1>Iterable;<endif>
<if(!sameTwoPrimitives)>import org.eclipse.collections.api.Lazy<name2>Iterable;<endif>
import org.eclipse.collections.api.Lazy<name1>Iterable;
import org.eclipse.collections.api.RichIterable;
import org.eclipse.collections.api.bag.MutableBag;
import org.eclipse.collections.api.bag.primitive.Mutable<name2>Bag;
import org.eclipse.collections.api.block.function.primitive.<name2>Function;
import org.eclipse.collections.api.block.function.primitive.<name2>Function0;
import org.eclipse.collections.api.block.function.primitive.<name2>To<name2>Function;
import org.eclipse.collections.api.block.function.primitive.<name2>ToObjectFunction;
import org.eclipse.collections.api.block.function.primitive.<name1><name2>To<name2>Function;
import org.eclipse.collections.api.block.function.primitive.Object<name2>ToObjectFunction;
<if(!sameTwoPrimitives)>import org.eclipse.collections.api.block.function.primitive.<name1>To<name2>Function;<endif>
import org.eclipse.collections.api.block.predicate.primitive.<name2>Predicate;
import org.eclipse.collections.api.block.predicate.primitive.<name1><name2>Predicate;
<if(!sameTwoPrimitives)>import org.eclipse.collections.api.block.procedure.primitive.<name2>Procedure;<endif>
import org.eclipse.collections.api.block.procedure.primitive.<name1><name2>Procedure;
import org.eclipse.collections.api.block.procedure.primitive.<name1>Procedure;
import org.eclipse.collections.api.collection.primitive.Mutable<name2>Collection;
import org.eclipse.collections.api.iterator.Mutable<name2>Iterator;
import org.eclipse.collections.api.list.primitive.Mutable<name2>List;
import org.eclipse.collections.api.map.primitive.Immutable<name1><name2>Map;
import org.eclipse.collections.api.map.primitive.<name1><name2>Map;
import org.eclipse.collections.api.map.primitive.Mutable<name1><name2>Map;
<if(!primitive2.booleanPrimitive)><if(!sameTwoPrimitives)>import org.eclipse.collections.api.map.primitive.Mutable<name2><name1>Map;<endif><endif>
<if(!sameTwoPrimitives)>import org.eclipse.collections.api.set.primitive.Mutable<name1>Set;<endif>
import org.eclipse.collections.api.set.primitive.Mutable<name2>Set;
import org.eclipse.collections.api.tuple.primitive.<name1><name2>Pair;
import org.eclipse.collections.impl.collection.mutable.primitive.Unmodifiable<name2>Collection;
import org.eclipse.collections.impl.factory.primitive.<name1><name2>Maps;
import org.eclipse.collections.impl.iterator.Unmodifiable<name2>Iterator;
import org.eclipse.collections.impl.set.mutable.primitive.Unmodifiable<name1>Set;

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

    public Unmodifiable<name1><name2>Map(Mutable<name1><name2>Map map)
    {
        if (map == null)
        {
            throw new IllegalArgumentException("Cannot create a Unmodifiable<name1><name2>Map on a null map");
        }

        this.map = map;
    }

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

    @Override
    public void put(<type1> key, <type2> value)
    {
        throw new UnsupportedOperationException("Cannot call put() on " + this.getClass().getSimpleName());
    }

    @Override
    public void putPair(<name1><name2>Pair keyValuePair)
    {
        throw new UnsupportedOperationException("Cannot call putPair() on " + this.getClass().getSimpleName());
    }

    @Override
    public void putAll(<name1><name2>Map map)
    {
        throw new UnsupportedOperationException("Cannot call putAll() on " + this.getClass().getSimpleName());
    }

    @Override
    public void updateValues(<name1><name2>To<name2>Function function)
    {
        throw new UnsupportedOperationException("Cannot call updateValues() on " + this.getClass().getSimpleName());
    }

    @Override
    public void removeKey(<type1> key)
    {
        throw new UnsupportedOperationException("Cannot call removeKey() on " + this.getClass().getSimpleName());
    }

    @Override
    public void remove(<type1> key)
    {
        throw new UnsupportedOperationException("Cannot call remove() on " + this.getClass().getSimpleName());
    }

    @Override
    public <type2> removeKeyIfAbsent(<type1> key, <type2> value)
    {
        if (this.map.containsKey(key))
        {
            throw new UnsupportedOperationException("Cannot call removeKey() on " + this.getClass().getSimpleName());
        }
        return value;
    }

    @Override
    public <type2> getIfAbsentPut(<type1> key, <type2> value)
    {
        return this.map.getIfAbsentPut(key, () -> { throw new UnsupportedOperationException(); });
    }

    @Override
    public <type2> getAndPut(<type1> key, <type2> putValue, <type2> defaultValue)
    {
        throw new UnsupportedOperationException("Cannot call remove() on " + this.getClass().getSimpleName());
    }

    @Override
    public <type2> getIfAbsentPut(<type1> key, <name2>Function0 function)
    {
        return this.map.getIfAbsentPut(key, () -> { throw new UnsupportedOperationException(); });
    }

    @Override
    public <type2> getIfAbsentPutWithKey(<type1> key, <name1>To<name2>Function function)
    {
        return this.map.getIfAbsentPut(key, () -> { throw new UnsupportedOperationException(); });
    }

    @Override
    public \<P> <type2> getIfAbsentPutWith(<type1> key, <name2>Function\<? super P> function, P parameter)
    {
        return this.map.getIfAbsentPut(key, () -> { throw new UnsupportedOperationException(); });
    }

    @Override
    public <type2> updateValue(<type1> key, <type2> initialValueIfAbsent, <name2>To<name2>Function function)
    {
        throw new UnsupportedOperationException("Cannot call updateValue() on " + this.getClass().getSimpleName());
    }

    @Override
    public <type2> get(<type1> key)
    {
        return this.map.get(key);
    }

    @Override
    public <type2> getIfAbsent(<type1> key, <type2> ifAbsent)
    {
        return this.map.getIfAbsent(key, ifAbsent);
    }

    @Override
    public <type2> getOrThrow(<type1> key)
    {
        return this.map.getOrThrow(key);
    }

    @Override
    public boolean containsKey(<type1> key)
    {
        return this.map.containsKey(key);
    }

    @Override
    public boolean containsValue(<type2> value)
    {
        return this.map.containsValue(value);
    }

    @Override
    public void forEachValue(<name2>Procedure procedure)
    {
        this.map.forEachValue(procedure);
    }

    @Override
    public void forEachKey(<name1>Procedure procedure)
    {
        this.map.forEachKey(procedure);
    }

    @Override
    public void forEachKeyValue(<name1><name2>Procedure procedure)
    {
        this.map.forEachKeyValue(procedure);
    }

    @Override
    public Lazy<name1>Iterable keysView()
    {
        return this.map.keysView();
    }

    @Override
    public RichIterable\<<name1><name2>Pair> keyValuesView()
    {
        return this.map.keyValuesView();
    }

    <if(!primitive2.booleanPrimitive)>
    @Override
    public Mutable<name2><name1>Map flipUniqueValues()
    {
        return this.map.flipUniqueValues().asUnmodifiable();
    }
    <endif>

    @Override
    public Mutable<name1><name2>Map select(<name1><name2>Predicate predicate)
    {
        return this.map.select(predicate);
    }

    @Override
    public Mutable<name1><name2>Map reject(<name1><name2>Predicate predicate)
    {
        return this.map.reject(predicate);
    }

    @Override
    public Mutable<name2>Iterator <type2>Iterator()
    {
        return new Unmodifiable<name2>Iterator(this.map.<type2>Iterator());
    }

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

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

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

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

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

    @Override
    public Mutable<name2>Bag select(<name2>Predicate predicate)
    {
        return this.map.select(predicate);
    }

    @Override
    public Mutable<name2>Bag reject(<name2>Predicate predicate)
    {
        return this.map.reject(predicate);
    }

    @Override
    public \<V> MutableBag\<V> collect(<name2>ToObjectFunction\<? extends V> function)
    {
        return this.map.collect(function);
    }

    @Override
    public <type2> detectIfNone(<name2>Predicate predicate, <type2> ifNone)
    {
        return this.map.detectIfNone(predicate, ifNone);
    }

    <(arithmeticMethods.(type2))(name2, type2)>
    @Override
    public <type2>[] toArray()
    {
        return this.map.toArray();
    }

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

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

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

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

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

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

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

    @Override
    public Lazy<name2>Iterable asLazy()
    {
        return this.map.asLazy();
    }

    @Override
    public Mutable<name1><name2>Map withKeyValue(<type1> key, <type2> value)
    {
        throw new UnsupportedOperationException("Cannot call withKeyValue() on " + this.getClass().getSimpleName());
    }

    @Override
    public Mutable<name1><name2>Map withoutKey(<type1> key)
    {
        throw new UnsupportedOperationException("Cannot call withoutKey() on " + this.getClass().getSimpleName());
    }

    @Override
    public Mutable<name1><name2>Map withoutAllKeys(<name1>Iterable keys)
    {
        throw new UnsupportedOperationException("Cannot call withoutAllKeys() on " + this.getClass().getSimpleName());
    }

    @Override
    public Mutable<name1><name2>Map asUnmodifiable()
    {
        return this;
    }

    @Override
    public Mutable<name1><name2>Map asSynchronized()
    {
        return new Synchronized<name1><name2>Map(this);
    }

    @Override
    public Immutable<name1><name2>Map toImmutable()
    {
        return <name1><name2>Maps.immutable.withAll(this);
    }

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

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

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

    @Override
    public Mutable<name1>Set keySet()
    {
        return Unmodifiable<name1>Set.of(this.map.keySet());
    }

    @Override
    public Mutable<name2>Collection values()
    {
        return Unmodifiable<name2>Collection.of(this.map.values());
    }

    @Override
    public boolean equals(Object otherMap)
    {
        return this.map.equals(otherMap);
    }

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

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

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

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

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

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

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

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

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

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

>>

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

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

@Override
public <type2> max()
{
    return this.map.max();
}

@Override
public <type2> maxIfEmpty(<type2> defaultValue)
{
    return this.map.maxIfEmpty(defaultValue);
}

@Override
public <type2> min()
{
    return this.map.min();
}

@Override
public <type2> minIfEmpty(<type2> defaultValue)
{
    return this.map.minIfEmpty(defaultValue);
}

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

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

@Override
public <type2> addToValue(<type1> key, <type2> toBeAdded)
{
    throw new UnsupportedOperationException("Cannot call addToValue() on " + this.getClass().getSimpleName());
}

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

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

>>

noMethods(name, type) ::= ""

