All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.gs.collections.impl.map.mutable.primitive.UnmodifiableShortObjectMap Maven / Gradle / Ivy

Go to download

GS Collections is a collections framework for Java. It has JDK-compatible List, Set and Map implementations with a rich API and set of utility classes that work with any JDK compatible Collections, Arrays, Maps or Strings. The iteration protocol was inspired by the Smalltalk collection framework.

There is a newer version: 7.0.3
Show newest version
/*
 * Copyright 2014 Goldman Sachs.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.gs.collections.impl.map.mutable.primitive;

import java.io.Serializable;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;

import com.gs.collections.api.ShortIterable;
import com.gs.collections.api.LazyShortIterable;
import com.gs.collections.api.LazyIterable;
import com.gs.collections.api.RichIterable;
import com.gs.collections.api.bag.MutableBag;
import com.gs.collections.impl.bag.mutable.HashBag;
import com.gs.collections.api.block.function.Function;
import com.gs.collections.api.block.function.Function0;
import com.gs.collections.api.block.function.Function2;
import com.gs.collections.api.bag.sorted.MutableSortedBag;
import com.gs.collections.api.block.function.primitive.BooleanFunction;
import com.gs.collections.api.block.function.primitive.ByteFunction;
import com.gs.collections.api.block.function.primitive.CharFunction;
import com.gs.collections.api.block.function.primitive.DoubleFunction;
import com.gs.collections.api.block.function.primitive.DoubleObjectToDoubleFunction;
import com.gs.collections.api.block.function.primitive.FloatFunction;
import com.gs.collections.api.block.function.primitive.FloatObjectToFloatFunction;
import com.gs.collections.api.block.function.primitive.IntFunction;
import com.gs.collections.api.block.function.primitive.IntObjectToIntFunction;
import com.gs.collections.api.block.function.primitive.ShortToObjectFunction;
import com.gs.collections.api.block.function.primitive.LongFunction;
import com.gs.collections.api.block.function.primitive.LongObjectToLongFunction;
import com.gs.collections.api.block.function.primitive.ShortFunction;
import com.gs.collections.api.block.predicate.Predicate;
import com.gs.collections.api.block.predicate.Predicate2;
import com.gs.collections.api.block.predicate.primitive.ShortObjectPredicate;
import com.gs.collections.api.block.procedure.Procedure;
import com.gs.collections.api.block.procedure.Procedure2;
import com.gs.collections.api.block.procedure.primitive.ShortObjectProcedure;
import com.gs.collections.api.block.procedure.primitive.ShortProcedure;
import com.gs.collections.api.block.procedure.primitive.ObjectIntProcedure;
import com.gs.collections.api.collection.MutableCollection;
import com.gs.collections.api.collection.primitive.MutableBooleanCollection;
import com.gs.collections.api.collection.primitive.MutableByteCollection;
import com.gs.collections.api.collection.primitive.MutableCharCollection;
import com.gs.collections.api.collection.primitive.MutableDoubleCollection;
import com.gs.collections.api.collection.primitive.MutableFloatCollection;
import com.gs.collections.api.collection.primitive.MutableIntCollection;
import com.gs.collections.api.collection.primitive.MutableLongCollection;
import com.gs.collections.api.collection.primitive.MutableShortCollection;
import com.gs.collections.api.list.MutableList;
import com.gs.collections.api.map.MutableMap;
import com.gs.collections.impl.multimap.bag.HashBagMultimap;
import com.gs.collections.api.multimap.bag.MutableBagMultimap;
import com.gs.collections.api.map.primitive.ImmutableShortObjectMap;
import com.gs.collections.api.map.primitive.MutableShortObjectMap;
import com.gs.collections.api.map.sorted.MutableSortedMap;
import com.gs.collections.api.multimap.MutableMultimap;
import com.gs.collections.api.map.primitive.ObjectDoubleMap;
import com.gs.collections.api.map.primitive.ObjectLongMap;
import com.gs.collections.api.map.primitive.ShortObjectMap;
import com.gs.collections.api.partition.PartitionMutableCollection;
import com.gs.collections.api.partition.bag.PartitionMutableBag;
import com.gs.collections.api.set.MutableSet;
import com.gs.collections.api.set.primitive.MutableShortSet;
import com.gs.collections.api.set.sorted.MutableSortedSet;
import com.gs.collections.api.ordered.OrderedIterable;
import com.gs.collections.api.tuple.Pair;
import com.gs.collections.api.tuple.primitive.ShortObjectPair;
import com.gs.collections.impl.UnmodifiableIteratorAdapter;
import com.gs.collections.impl.factory.primitive.ShortObjectMaps;
import com.gs.collections.impl.set.mutable.primitive.UnmodifiableShortSet;

/**
 * This file was automatically generated from template file unmodifiablePrimitiveObjectMap.stg.
 *
 * @since 3.2.
 */
public final class UnmodifiableShortObjectMap
        implements MutableShortObjectMap, Serializable
{
    private static final long serialVersionUID = 1L;
    private final MutableShortObjectMap map;

    UnmodifiableShortObjectMap(MutableShortObjectMap map)
    {
        this.map = map;
    }

    private boolean isAbsent(V result, short key)
    {
        return result == null && !this.containsKey(key);
    }

    private V getIfAbsentThrow(short key)
    {
        V result = this.map.get(key);
        if (this.isAbsent(result, key))
        {
            throw new UnsupportedOperationException("Cannot add to an " + this.getClass().getSimpleName());
        }
        return result;
    }

    public V put(short key, V value)
    {
        throw new UnsupportedOperationException("Cannot call put() on " + this.getClass().getSimpleName());
    }

    public void putAll(ShortObjectMap map)
    {
        throw new UnsupportedOperationException("Cannot call putAll() on " + this.getClass().getSimpleName());
    }

    public V removeKey(short key)
    {
        throw new UnsupportedOperationException("Cannot call removeKey() on " + this.getClass().getSimpleName());
    }

    public V remove(short key)
    {
        throw new UnsupportedOperationException("Cannot call remove() on " + this.getClass().getSimpleName());
    }

    public V getIfAbsentPut(short key, Function0 function)
    {
        return this.getIfAbsentThrow(key);
    }

    public V getIfAbsentPut(short key, V value)
    {
        return this.getIfAbsentThrow(key);
    }

    public V getIfAbsentPutWithKey(short key, ShortToObjectFunction function)
    {
        return this.getIfAbsentThrow(key);
    }

    public 

V getIfAbsentPutWith(short key, Function function, P parameter) { return this.getIfAbsentThrow(key); } public V updateValue(short key, Function0 factory, Function function) { throw new UnsupportedOperationException("Cannot call updateValue() on " + this.getClass().getSimpleName()); } public

V updateValueWith(short key, Function0 factory, Function2 function, P parameter) { throw new UnsupportedOperationException("Cannot call updateValueWith() on " + this.getClass().getSimpleName()); } public V get(short key) { return this.map.get(key); } public V getIfAbsent(short key, Function0 ifAbsent) { return this.map.getIfAbsent(key, ifAbsent); } public boolean containsKey(short key) { return this.map.containsKey(key); } public boolean containsValue(Object value) { return this.map.containsValue(value); } public MutableShortObjectMap tap(Procedure procedure) { this.map.forEach(procedure); return this; } public void forEachValue(Procedure procedure) { this.map.forEachValue(procedure); } public void forEachKey(ShortProcedure procedure) { this.map.forEachKey(procedure); } public void forEachKeyValue(ShortObjectProcedure procedure) { this.map.forEachKeyValue(procedure); } public MutableShortObjectMap select(ShortObjectPredicate predicate) { return this.map.select(predicate); } public MutableShortObjectMap reject(ShortObjectPredicate predicate) { return this.map.reject(predicate); } public int size() { return this.map.size(); } public boolean isEmpty() { return this.map.isEmpty(); } public boolean notEmpty() { return this.map.notEmpty(); } public V getFirst() { return this.map.getFirst(); } public V getLast() { return this.map.getLast(); } public boolean contains(Object object) { return this.map.contains(object); } public boolean containsAllIterable(Iterable source) { return this.map.containsAllIterable(source); } public boolean containsAll(Collection source) { return this.map.containsAll(source); } public boolean containsAllArguments(Object... elements) { return this.map.containsAllArguments(elements); } public MutableCollection select(Predicate predicate) { return this.map.select(predicate); } public > R select(Predicate predicate, R target) { return this.map.select(predicate, target); } public

MutableCollection selectWith(Predicate2 predicate, P parameter) { return this.map.selectWith(predicate, parameter); } public > R selectWith(Predicate2 predicate, P parameter, R targetCollection) { return this.map.selectWith(predicate, parameter, targetCollection); } public PartitionMutableBag partition(Predicate predicate) { return this.map.partition(predicate); } public

PartitionMutableBag partitionWith(Predicate2 predicate, P parameter) { return this.map.partitionWith(predicate, parameter); } public MutableBag selectInstancesOf(Class clazz) { return this.map.selectInstancesOf(clazz); } /** * @deprecated in 7.0. Use {@link OrderedIterable#zipWithIndex} instead. */ @Deprecated public MutableSet> zipWithIndex() { return this.map.zipWithIndex(); } public >> R zipWithIndex(R target) { return this.map.zipWithIndex(target); } public RichIterable> chunk(int size) { return this.map.chunk(size); } public MutableMap aggregateInPlaceBy(Function groupBy, Function0 zeroValueFactory, Procedure2 mutatingAggregator) { return this.map.aggregateInPlaceBy(groupBy, zeroValueFactory, mutatingAggregator); } public MutableMap aggregateBy(Function groupBy, Function0 zeroValueFactory, Function2 nonMutatingAggregator) { return this.map.aggregateBy(groupBy, zeroValueFactory, nonMutatingAggregator); } public MutableCollection reject(Predicate predicate) { return this.map.reject(predicate); } public > R reject(Predicate predicate, R target) { return this.map.reject(predicate, target); } public

MutableCollection rejectWith(Predicate2 predicate, P parameter) { return this.map.rejectWith(predicate, parameter); } public > R rejectWith(Predicate2 predicate, P parameter, R targetCollection) { return this.map.rejectWith(predicate, parameter, targetCollection); } public void clear() { throw new UnsupportedOperationException("Cannot call clear() on " + this.getClass().getSimpleName()); } public MutableCollection collect(Function function) { return this.map.collect(function); } public MutableBooleanCollection collectBoolean(BooleanFunction booleanFunction) { return this.map.collectBoolean(booleanFunction); } public R collectBoolean(BooleanFunction booleanFunction, R target) { return this.map.collectBoolean(booleanFunction, target); } public MutableByteCollection collectByte(ByteFunction byteFunction) { return this.map.collectByte(byteFunction); } public R collectByte(ByteFunction byteFunction, R target) { return this.map.collectByte(byteFunction, target); } public MutableCharCollection collectChar(CharFunction charFunction) { return this.map.collectChar(charFunction); } public R collectChar(CharFunction charFunction, R target) { return this.map.collectChar(charFunction, target); } public MutableDoubleCollection collectDouble(DoubleFunction doubleFunction) { return this.map.collectDouble(doubleFunction); } public R collectDouble(DoubleFunction doubleFunction, R target) { return this.map.collectDouble(doubleFunction, target); } public MutableFloatCollection collectFloat(FloatFunction floatFunction) { return this.map.collectFloat(floatFunction); } public R collectFloat(FloatFunction floatFunction, R target) { return this.map.collectFloat(floatFunction, target); } public MutableIntCollection collectInt(IntFunction intFunction) { return this.map.collectInt(intFunction); } public R collectInt(IntFunction intFunction, R target) { return this.map.collectInt(intFunction, target); } public MutableLongCollection collectLong(LongFunction longFunction) { return this.map.collectLong(longFunction); } public R collectLong(LongFunction longFunction, R target) { return this.map.collectLong(longFunction, target); } public MutableShortCollection collectShort(ShortFunction shortFunction) { return this.map.collectShort(shortFunction); } public R collectShort(ShortFunction shortFunction, R target) { return this.map.collectShort(shortFunction, target); } public MutableCollection collectWith(Function2 function, P parameter) { return this.map.collectWith(function, parameter); } public > R collectWith(Function2 function, P parameter, R targetCollection) { return this.map.collectWith(function, parameter, targetCollection); } public > R collect(Function function, R target) { return this.map.collect(function, target); } public MutableBag collectIf(Predicate predicate, Function function) { return this.map.collectIf(predicate, function); } public > R collectIf(Predicate predicate, Function function, R target) { return this.map.collectIf(predicate, function, target); } public RichIterable flatCollect(Function> function) { return this.map.flatCollect(function); } public > R flatCollect(Function> function, R target) { return this.map.flatCollect(function, target); } public V detect(Predicate predicate) { return this.map.detect(predicate); } public

V detectWith(Predicate2 predicate, P parameter) { return this.map.detectWith(predicate, parameter); } public V detectIfNone(Predicate predicate, Function0 function) { return this.map.detectIfNone(predicate, function); } public

V detectWithIfNone(Predicate2 predicate, P parameter, Function0 function) { return this.map.detectWithIfNone(predicate, parameter, function); } public int count(Predicate predicate) { return this.map.count(predicate); } public

int countWith(Predicate2 predicate, P parameter) { return this.map.countWith(predicate, parameter); } public boolean anySatisfy(Predicate predicate) { return this.map.anySatisfy(predicate); } public

boolean anySatisfyWith(Predicate2 predicate, P parameter) { return this.map.anySatisfyWith(predicate, parameter); } public boolean allSatisfy(Predicate predicate) { return this.map.allSatisfy(predicate); } public

boolean allSatisfyWith(Predicate2 predicate, P parameter) { return this.map.allSatisfyWith(predicate, parameter); } public boolean noneSatisfy(Predicate predicate) { return this.map.noneSatisfy(predicate); } public

boolean noneSatisfyWith(Predicate2 predicate, P parameter) { return this.map.noneSatisfyWith(predicate, parameter); } public IV injectInto(IV injectedValue, Function2 function) { return this.map.injectInto(injectedValue, function); } public int injectInto(int injectedValue, IntObjectToIntFunction function) { return this.map.injectInto(injectedValue, function); } public long injectInto(long injectedValue, LongObjectToLongFunction function) { return this.map.injectInto(injectedValue, function); } public float injectInto(float injectedValue, FloatObjectToFloatFunction function) { return this.map.injectInto(injectedValue, function); } public double injectInto(double injectedValue, DoubleObjectToDoubleFunction function) { return this.map.injectInto(injectedValue, function); } public MutableList toList() { return this.map.toList(); } public MutableList toSortedList() { return this.map.toSortedList(); } public MutableList toSortedList(Comparator comparator) { return this.map.toSortedList(comparator); } public > MutableList toSortedListBy(Function function) { return this.map.toSortedListBy(function); } public MutableSet toSet() { return this.map.toSet(); } public MutableSortedSet toSortedSet() { return this.map.toSortedSet(); } public MutableSortedSet toSortedSet(Comparator comparator) { return this.map.toSortedSet(comparator); } public > MutableSortedSet toSortedSetBy(Function function) { return this.map.toSortedSetBy(function); } public MutableBag toBag() { return this.map.toBag(); } public MutableSortedBag toSortedBag() { return this.map.toSortedBag(); } public MutableSortedBag toSortedBag(Comparator comparator) { return this.map.toSortedBag(comparator); } public > MutableSortedBag toSortedBagBy(Function function) { return this.map.toSortedBagBy(function); } public MutableMap toMap(Function keyFunction, Function valueFunction) { return this.map.toMap(keyFunction, valueFunction); } public MutableSortedMap toSortedMap(Function keyFunction, Function valueFunction) { return this.map.toSortedMap(keyFunction, valueFunction); } public MutableSortedMap toSortedMap(Comparator comparator, Function keyFunction, Function valueFunction) { return this.map.toSortedMap(comparator, keyFunction, valueFunction); } public LazyIterable asLazy() { return this.map.asLazy(); } public Object[] toArray() { return this.map.toArray(); } public T[] toArray(T[] a) { return this.map.toArray(a); } public V min(Comparator comparator) { return this.map.min(comparator); } public V max(Comparator comparator) { return this.map.max(comparator); } public V min() { return this.map.min(); } public V max() { return this.map.max(); } public > V maxBy(Function function) { return this.map.maxBy(function); } public > V minBy(Function function) { return this.map.minBy(function); } public long sumOfInt(IntFunction function) { return this.map.sumOfInt(function); } public double sumOfFloat(FloatFunction function) { return this.map.sumOfFloat(function); } public long sumOfLong(LongFunction function) { return this.map.sumOfLong(function); } public double sumOfDouble(DoubleFunction function) { return this.map.sumOfDouble(function); } public ObjectLongMap sumByInt(Function groupBy, IntFunction function) { return this.map.sumByInt(groupBy, function); } public ObjectDoubleMap sumByFloat(Function groupBy, FloatFunction function) { return this.map.sumByFloat(groupBy, function); } public ObjectLongMap sumByLong(Function groupBy, LongFunction function) { return this.map.sumByLong(groupBy, function); } public ObjectDoubleMap sumByDouble(Function groupBy, DoubleFunction function) { return this.map.sumByDouble(groupBy, function); } public MutableShortSet keySet() { return UnmodifiableShortSet.of(this.map.keySet()); } public Collection values() { return Collections.unmodifiableCollection(this.map.values()); } public LazyShortIterable keysView() { return this.map.keysView(); } public RichIterable> keyValuesView() { return this.map.keyValuesView(); } @Override public boolean equals(Object obj) { return this.map.equals(obj); } @Override public int hashCode() { return this.map.hashCode(); } @Override public String toString() { return this.map.toString(); } public String makeString() { return this.map.makeString(); } public String makeString(String separator) { return this.map.makeString(separator); } public String makeString(String start, String separator, String end) { return this.map.makeString(start, separator, end); } public void appendString(Appendable appendable) { this.map.appendString(appendable); } public void appendString(Appendable appendable, String separator) { this.map.appendString(appendable, separator); } public void appendString(Appendable appendable, String start, String separator, String end) { this.map.appendString(appendable, start, separator, end); } public MutableBagMultimap groupBy(Function function) { return this.map.groupBy(function); } public > R groupBy(Function function, R target) { return this.map.groupBy(function, target); } public MutableBagMultimap groupByEach(Function> function) { return this.map.groupByEach(function); } public > R groupByEach(Function> function, R target) { return this.map.groupByEach(function, target); } public MutableMap groupByUniqueKey(Function function) { return this.map.groupByUniqueKey(function); } public > R groupByUniqueKey(Function function, R target) { return this.map.groupByUniqueKey(function, target); } /** * @deprecated in 7.0. Use {@link OrderedIterable#zip(Iterable)} instead. */ @Deprecated public MutableBag> zip(Iterable that) { return this.map.zip(that); } public >> R zip(Iterable that, R target) { return this.map.zip(that, target); } public MutableShortObjectMap withKeyValue(short key, V value) { throw new UnsupportedOperationException("Cannot call withKeyValue() on " + this.getClass().getSimpleName()); } public MutableShortObjectMap withoutKey(short key) { throw new UnsupportedOperationException("Cannot call withoutKey() on " + this.getClass().getSimpleName()); } public MutableShortObjectMap withoutAllKeys(ShortIterable keys) { throw new UnsupportedOperationException("Cannot call withoutAllKeys() on " + this.getClass().getSimpleName()); } public MutableShortObjectMap asUnmodifiable() { return this; } public MutableShortObjectMap asSynchronized() { return new SynchronizedShortObjectMap(this); } public ImmutableShortObjectMap toImmutable() { return ShortObjectMaps.immutable.withAll(this); } public void forEach(Procedure procedure) { this.each(procedure); } public void each(Procedure procedure) { this.map.forEach(procedure); } public void forEachWithIndex(ObjectIntProcedure objectIntProcedure) { this.map.forEachWithIndex(objectIntProcedure); } public

void forEachWith(Procedure2 procedure, P parameter) { this.map.forEachWith(procedure, parameter); } public Iterator iterator() { return new UnmodifiableIteratorAdapter(this.map.iterator()); } }