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

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

/*
 * 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.CharIterable;
import com.gs.collections.api.LazyCharIterable;
import com.gs.collections.api.LazyIterable;
import com.gs.collections.api.RichIterable;
import com.gs.collections.api.bag.MutableBag;
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.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.CharToObjectFunction;
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.CharObjectPredicate;
import com.gs.collections.api.block.procedure.Procedure;
import com.gs.collections.api.block.procedure.Procedure2;
import com.gs.collections.api.block.procedure.primitive.CharObjectProcedure;
import com.gs.collections.api.block.procedure.primitive.CharProcedure;
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.api.map.primitive.CharObjectMap;
import com.gs.collections.api.map.primitive.ImmutableCharObjectMap;
import com.gs.collections.api.map.primitive.MutableCharObjectMap;
import com.gs.collections.api.map.sorted.MutableSortedMap;
import com.gs.collections.api.multimap.MutableMultimap;
import com.gs.collections.api.partition.PartitionMutableCollection;
import com.gs.collections.api.set.MutableSet;
import com.gs.collections.api.set.primitive.MutableCharSet;
import com.gs.collections.api.set.sorted.MutableSortedSet;
import com.gs.collections.api.tuple.Pair;
import com.gs.collections.api.tuple.primitive.CharObjectPair;
import com.gs.collections.impl.SynchronizedRichIterable;
import com.gs.collections.impl.collection.mutable.CollectionAdapter;
import com.gs.collections.impl.collection.mutable.SynchronizedMutableCollection;
import com.gs.collections.impl.factory.primitive.CharObjectMaps;
import com.gs.collections.impl.primitive.SynchronizedCharIterable;
import com.gs.collections.impl.set.mutable.primitive.SynchronizedCharSet;
import net.jcip.annotations.GuardedBy;

/**
 * A synchronized view of a {@link MutableCharObjectMap}. It is imperative that the user manually synchronize on the collection when iterating over it using the
 * standard JDK iterator or JDK 5 for loop, as per {@link Collections#synchronizedCollection(Collection)}.
 * 

* This file was automatically generated from template file synchronizedPrimitiveObjectMap.stg. *

* * @see MutableCharObjectMap#asSynchronized() * @see MutableMap#asSynchronized() * @since 3.1. */ public final class SynchronizedCharObjectMap implements MutableCharObjectMap, Serializable { private static final long serialVersionUID = 1L; private final Object lock; @GuardedBy("this.lock") private final MutableCharObjectMap map; SynchronizedCharObjectMap(MutableCharObjectMap map) { this(map, null); } SynchronizedCharObjectMap(MutableCharObjectMap map, Object newLock) { this.map = map; this.lock = newLock == null ? this : newLock; } public V put(char key, V value) { synchronized (this.lock) { return this.map.put(key, value); } } public void putAll(CharObjectMap map) { synchronized (this.lock) { map.forEachKeyValue(new CharObjectProcedure() { public void value(char key, V value) { SynchronizedCharObjectMap.this.map.put(key, value); } }); } } public V removeKey(char key) { synchronized (this.lock) { return this.map.removeKey(key); } } public V remove(char key) { synchronized (this.lock) { return this.map.remove(key); } } public V getIfAbsentPut(char key, V value) { synchronized (this.lock) { return this.map.getIfAbsentPut(key, value); } } public V getIfAbsentPut(char key, Function0 function) { synchronized (this.lock) { return this.map.getIfAbsentPut(key, function); } } public V getIfAbsentPutWithKey(char key, CharToObjectFunction function) { synchronized (this.lock) { return this.map.getIfAbsentPutWithKey(key, function); } } public

V getIfAbsentPutWith(char key, Function function, P parameter) { synchronized (this.lock) { return this.map.getIfAbsentPutWith(key, function, parameter); } } public V updateValue(char key, Function0 factory, Function function) { synchronized (this.lock) { return this.map.updateValue(key, factory, function); } } public

V updateValueWith(char key, Function0 factory, Function2 function, P parameter) { synchronized (this.lock) { return this.map.updateValueWith(key, factory, function, parameter); } } public V get(char key) { synchronized (this.lock) { return this.map.get(key); } } public V getIfAbsent(char key, Function0 ifAbsent) { synchronized (this.lock) { return this.map.getIfAbsent(key, ifAbsent); } } public boolean containsKey(char key) { synchronized (this.lock) { return this.map.containsKey(key); } } public boolean containsValue(Object value) { synchronized (this.lock) { return this.map.containsValue(value); } } public void forEachValue(Procedure procedure) { synchronized (this.lock) { this.map.forEachValue(procedure); } } public void forEachKey(CharProcedure procedure) { synchronized (this.lock) { this.map.forEachKey(procedure); } } public void forEachKeyValue(CharObjectProcedure procedure) { synchronized (this.lock) { this.map.forEachKeyValue(procedure); } } public MutableCharObjectMap select(CharObjectPredicate predicate) { synchronized (this.lock) { return this.map.select(predicate); } } public MutableCharObjectMap reject(CharObjectPredicate predicate) { synchronized (this.lock) { return this.map.reject(predicate); } } public int size() { synchronized (this.lock) { return this.map.size(); } } public boolean isEmpty() { synchronized (this.lock) { return this.map.isEmpty(); } } public boolean notEmpty() { synchronized (this.lock) { return this.map.notEmpty(); } } public V getFirst() { synchronized (this.lock) { return this.map.getFirst(); } } public V getLast() { synchronized (this.lock) { return this.map.getLast(); } } public boolean contains(Object object) { synchronized (this.lock) { return this.map.contains(object); } } public boolean containsAllIterable(Iterable source) { synchronized (this.lock) { return this.map.containsAllIterable(source); } } public boolean containsAll(Collection source) { synchronized (this.lock) { return this.map.containsAll(source); } } public boolean containsAllArguments(Object... elements) { synchronized (this.lock) { return this.map.containsAllArguments(elements); } } public MutableCollection select(Predicate predicate) { synchronized (this.lock) { return this.map.select(predicate); } } public > R select(Predicate predicate, R target) { synchronized (this.lock) { return this.map.select(predicate, target); } } public

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

PartitionMutableCollection partitionWith(Predicate2 predicate, P parameter) { synchronized (this.lock) { return this.map.partitionWith(predicate, parameter); } } public MutableCollection selectInstancesOf(Class clazz) { synchronized (this.lock) { return this.map.selectInstancesOf(clazz); } } public MutableList> zipWithIndex() { synchronized (this.lock) { return (MutableList>) this.map.zipWithIndex(); } } public >> R zipWithIndex(R target) { synchronized (this.lock) { return this.map.zipWithIndex(target); } } public RichIterable> chunk(int size) { synchronized (this.lock) { return this.map.chunk(size); } } public MutableMap aggregateInPlaceBy(Function groupBy, Function0 zeroValueFactory, Procedure2 mutatingAggregator) { synchronized (this.lock) { return this.map.aggregateInPlaceBy(groupBy, zeroValueFactory, mutatingAggregator); } } public MutableMap aggregateBy(Function groupBy, Function0 zeroValueFactory, Function2 nonMutatingAggregator) { synchronized (this.lock) { return this.map.aggregateBy(groupBy, zeroValueFactory, nonMutatingAggregator); } } public MutableCollection reject(Predicate predicate) { synchronized (this.lock) { return this.map.reject(predicate); } } public > R reject(Predicate predicate, R target) { synchronized (this.lock) { return this.map.reject(predicate, target); } } public

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

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

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

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

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

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

boolean noneSatisfyWith(Predicate2 predicate, P parameter) { synchronized (this.lock) { return this.map.noneSatisfyWith(predicate, parameter); } } public IV injectInto(IV injectedValue, Function2 function) { synchronized (this.lock) { return this.map.injectInto(injectedValue, function); } } public int injectInto(int injectedValue, IntObjectToIntFunction function) { synchronized (this.lock) { return this.map.injectInto(injectedValue, function); } } public long injectInto(long injectedValue, LongObjectToLongFunction function) { synchronized (this.lock) { return this.map.injectInto(injectedValue, function); } } public float injectInto(float injectedValue, FloatObjectToFloatFunction function) { synchronized (this.lock) { return this.map.injectInto(injectedValue, function); } } public double injectInto(double injectedValue, DoubleObjectToDoubleFunction function) { synchronized (this.lock) { return this.map.injectInto(injectedValue, function); } } public MutableList toList() { synchronized (this.lock) { return this.map.toList(); } } public MutableList toSortedList() { synchronized (this.lock) { return this.map.toSortedList(); } } public MutableList toSortedList(Comparator comparator) { synchronized (this.lock) { return this.map.toSortedList(comparator); } } public > MutableList toSortedListBy(Function function) { synchronized (this.lock) { return this.map.toSortedListBy(function); } } public MutableSet toSet() { synchronized (this.lock) { return this.map.toSet(); } } public MutableSortedSet toSortedSet() { synchronized (this.lock) { return this.map.toSortedSet(); } } public MutableSortedSet toSortedSet(Comparator comparator) { synchronized (this.lock) { return this.map.toSortedSet(comparator); } } public > MutableSortedSet toSortedSetBy(Function function) { synchronized (this.lock) { return this.map.toSortedSetBy(function); } } public MutableBag toBag() { synchronized (this.lock) { return this.map.toBag(); } } public MutableMap toMap(Function keyFunction, Function valueFunction) { synchronized (this.lock) { return this.map.toMap(keyFunction, valueFunction); } } public MutableSortedMap toSortedMap(Function keyFunction, Function valueFunction) { synchronized (this.lock) { return this.map.toSortedMap(keyFunction, valueFunction); } } public MutableSortedMap toSortedMap(Comparator comparator, Function keyFunction, Function valueFunction) { synchronized (this.lock) { return this.map.toSortedMap(comparator, keyFunction, valueFunction); } } public LazyIterable asLazy() { synchronized (this.lock) { return this.map.asLazy(); } } public Object[] toArray() { synchronized (this.lock) { return this.map.toArray(); } } public T[] toArray(T[] a) { synchronized (this.lock) { return this.map.toArray(a); } } public V min(Comparator comparator) { synchronized (this.lock) { return this.map.min(comparator); } } public V max(Comparator comparator) { synchronized (this.lock) { return this.map.max(comparator); } } public V min() { synchronized (this.lock) { return this.map.min(); } } public V max() { synchronized (this.lock) { return this.map.max(); } } public > V maxBy(Function function) { synchronized (this.lock) { return this.map.maxBy(function); } } public > V minBy(Function function) { synchronized (this.lock) { return this.map.minBy(function); } } public long sumOfInt(IntFunction function) { synchronized (this.lock) { return this.map.sumOfInt(function); } } public double sumOfFloat(FloatFunction function) { synchronized (this.lock) { return this.map.sumOfFloat(function); } } public long sumOfLong(LongFunction function) { synchronized (this.lock) { return this.map.sumOfLong(function); } } public double sumOfDouble(DoubleFunction function) { synchronized (this.lock) { return this.map.sumOfDouble(function); } } public MutableCharSet keySet() { synchronized (this.lock) { return SynchronizedCharSet.of(this.map.keySet(), this.lock); } } public Collection values() { synchronized (this.lock) { return SynchronizedMutableCollection.of(CollectionAdapter.adapt(this.map.values()), this.lock); } } public LazyCharIterable keysView() { synchronized (this.lock) { return SynchronizedCharIterable.of(this.map.keysView(), this.lock).asLazy(); } } public RichIterable> keyValuesView() { synchronized (this.lock) { return SynchronizedRichIterable.of(this.map.keyValuesView(), this.lock).asLazy(); } } @Override public boolean equals(Object obj) { synchronized (this.lock) { return this.map.equals(obj); } } @Override public int hashCode() { synchronized (this.lock) { return this.map.hashCode(); } } @Override public String toString() { synchronized (this.lock) { return this.map.toString(); } } public String makeString() { synchronized (this.lock) { return this.map.makeString(); } } public String makeString(String separator) { synchronized (this.lock) { return this.map.makeString(separator); } } public String makeString(String start, String separator, String end) { synchronized (this.lock) { return this.map.makeString(start, separator, end); } } public void appendString(Appendable appendable) { synchronized (this.lock) { this.map.appendString(appendable); } } public void appendString(Appendable appendable, String separator) { synchronized (this.lock) { this.map.appendString(appendable, separator); } } public void appendString(Appendable appendable, String start, String separator, String end) { synchronized (this.lock) { this.map.appendString(appendable, start, separator, end); } } public MutableMultimap groupBy(Function function) { synchronized (this.lock) { return this.map.groupBy(function); } } public > R groupBy(Function function, R target) { synchronized (this.lock) { return this.map.groupBy(function, target); } } public MutableMultimap groupByEach(Function> function) { synchronized (this.lock) { return this.map.groupByEach(function); } } public > R groupByEach(Function> function, R target) { synchronized (this.lock) { return this.map.groupByEach(function, target); } } public MutableMap groupByUniqueKey(Function function) { synchronized (this.lock) { return this.map.groupByUniqueKey(function); } } public MutableCollection> zip(Iterable that) { synchronized (this.lock) { return this.map.zip(that); } } public >> R zip(Iterable that, R target) { synchronized (this.lock) { return this.map.zip(that, target); } } public MutableCharObjectMap withKeyValue(char key, V value) { synchronized (this.lock) { this.map.withKeyValue(key, value); } return this; } public MutableCharObjectMap withoutKey(char key) { synchronized (this.lock) { this.map.withoutKey(key); } return this; } public MutableCharObjectMap withoutAllKeys(CharIterable keys) { synchronized (this.lock) { this.map.withoutAllKeys(keys); } return this; } public MutableCharObjectMap asUnmodifiable() { return new UnmodifiableCharObjectMap(this); } public MutableCharObjectMap asSynchronized() { return this; } public ImmutableCharObjectMap toImmutable() { return CharObjectMaps.immutable.withAll(this); } public void forEach(Procedure procedure) { synchronized (this.lock) { this.map.forEach(procedure); } } public void forEachWithIndex(ObjectIntProcedure objectIntProcedure) { synchronized (this.lock) { this.map.forEachWithIndex(objectIntProcedure); } } public

void forEachWith(Procedure2 procedure, P parameter) { synchronized (this.lock) { this.map.forEachWith(procedure, parameter); } } /** * Must be called in a synchronized block. */ public Iterator iterator() { return this.map.iterator(); } }