/*
 * Copyright (c) 2018 Goldman Sachs and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * and Eclipse Distribution License v. 1.0 which accompany this distribution.
 * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
 * and the Eclipse Distribution License is available at
 * http://www.eclipse.org/org/documents/edl-v10.php.
 */

package org.eclipse.collections.impl.collection;

import java.util.Collection;
import java.util.Comparator;
import java.util.Iterator;
import java.util.Map;
import java.util.Optional;

import org.eclipse.collections.api.BooleanIterable;
import org.eclipse.collections.api.ByteIterable;
import org.eclipse.collections.api.CharIterable;
import org.eclipse.collections.api.DoubleIterable;
import org.eclipse.collections.api.FloatIterable;
import org.eclipse.collections.api.IntIterable;
import org.eclipse.collections.api.LazyIterable;
import org.eclipse.collections.api.LongIterable;
import org.eclipse.collections.api.RichIterable;
import org.eclipse.collections.api.ShortIterable;
import org.eclipse.collections.api.bag.Bag;
import org.eclipse.collections.api.bag.MutableBag;
import org.eclipse.collections.api.bag.MutableBagIterable;
import org.eclipse.collections.api.bag.sorted.MutableSortedBag;
import org.eclipse.collections.api.bimap.MutableBiMap;
import org.eclipse.collections.api.block.function.Function;
import org.eclipse.collections.api.block.function.Function0;
import org.eclipse.collections.api.block.function.Function2;
import org.eclipse.collections.api.block.function.primitive.BooleanFunction;
import org.eclipse.collections.api.block.function.primitive.ByteFunction;
import org.eclipse.collections.api.block.function.primitive.CharFunction;
import org.eclipse.collections.api.block.function.primitive.DoubleFunction;
import org.eclipse.collections.api.block.function.primitive.DoubleObjectToDoubleFunction;
import org.eclipse.collections.api.block.function.primitive.FloatFunction;
import org.eclipse.collections.api.block.function.primitive.FloatObjectToFloatFunction;
import org.eclipse.collections.api.block.function.primitive.IntFunction;
import org.eclipse.collections.api.block.function.primitive.IntObjectToIntFunction;
import org.eclipse.collections.api.block.function.primitive.LongFunction;
import org.eclipse.collections.api.block.function.primitive.LongObjectToLongFunction;
import org.eclipse.collections.api.block.function.primitive.ShortFunction;
import org.eclipse.collections.api.block.predicate.Predicate;
import org.eclipse.collections.api.block.predicate.Predicate2;
import org.eclipse.collections.api.block.procedure.Procedure;
import org.eclipse.collections.api.block.procedure.Procedure2;
import org.eclipse.collections.api.block.procedure.primitive.ObjectIntProcedure;
import org.eclipse.collections.api.collection.primitive.MutableBooleanCollection;
import org.eclipse.collections.api.collection.primitive.MutableByteCollection;
import org.eclipse.collections.api.collection.primitive.MutableCharCollection;
import org.eclipse.collections.api.collection.primitive.MutableDoubleCollection;
import org.eclipse.collections.api.collection.primitive.MutableFloatCollection;
import org.eclipse.collections.api.collection.primitive.MutableIntCollection;
import org.eclipse.collections.api.collection.primitive.MutableLongCollection;
import org.eclipse.collections.api.collection.primitive.MutableShortCollection;
import org.eclipse.collections.api.list.MutableList;
import org.eclipse.collections.api.map.MapIterable;
import org.eclipse.collections.api.map.MutableMap;
import org.eclipse.collections.api.map.MutableMapIterable;
import org.eclipse.collections.api.map.primitive.ObjectDoubleMap;
import org.eclipse.collections.api.map.primitive.ObjectLongMap;
import org.eclipse.collections.api.map.sorted.MutableSortedMap;
import org.eclipse.collections.api.multimap.Multimap;
import org.eclipse.collections.api.multimap.MutableMultimap;
import org.eclipse.collections.api.partition.PartitionIterable;
import org.eclipse.collections.api.set.MutableSet;
import org.eclipse.collections.api.set.sorted.MutableSortedSet;
import org.eclipse.collections.api.tuple.Pair;
import org.eclipse.collections.impl.block.factory.Comparators;
import org.eclipse.collections.impl.map.mutable.UnifiedMap;
import org.eclipse.collections.impl.utility.LazyIterate;

public abstract class AbstractSynchronizedRichIterable<T> implements RichIterable<T>
{
    protected final Object lock;
    protected final RichIterable<T> delegate;

    protected AbstractSynchronizedRichIterable(RichIterable<T> delegate, Object lock)
    {
        if (delegate == null)
        {
            throw new IllegalArgumentException("Cannot create a AbstractSynchronizedRichIterable on a null collection");
        }

        this.delegate = delegate;
        this.lock = lock == null ? this : lock;
    }

    protected RichIterable<T> getDelegate()
    {
        return this.delegate;
    }

    protected Object getLock()
    {
        return this.lock;
    }

    @Override
    public boolean equals(Object obj)
    {
        synchronized (this.lock)
        {
            return this.delegate.equals(obj);
        }
    }

    @Override
    public int hashCode()
    {
        synchronized (this.lock)
        {
            return this.delegate.hashCode();
        }
    }

    @Override
    public String toString()
    {
        synchronized (this.lock)
        {
            return this.delegate.toString();
        }
    }

    
Must be called in a synchronized block.
/** * Must be called in a synchronized block. */
@Override public Iterator<T> iterator() { return this.delegate.iterator(); } @Override public void forEach(Procedure<? super T> procedure) { this.each(procedure); } @Override public void forEachWithIndex(ObjectIntProcedure<? super T> objectIntProcedure) { synchronized (this.lock) { this.delegate.forEachWithIndex(objectIntProcedure); } } @Override public <P> void forEachWith(Procedure2<? super T, ? super P> procedure, P parameter) { synchronized (this.lock) { this.delegate.forEachWith(procedure, parameter); } } @Override public int size() { synchronized (this.lock) { return this.delegate.size(); } } @Override public boolean isEmpty() { synchronized (this.lock) { return this.delegate.isEmpty(); } } @Override public boolean notEmpty() { synchronized (this.lock) { return this.delegate.notEmpty(); } } @Override public T getFirst() { synchronized (this.lock) { return this.delegate.getFirst(); } } @Override public T getLast() { synchronized (this.lock) { return this.delegate.getLast(); } } @Override public boolean contains(Object o) { synchronized (this.lock) { return this.delegate.contains(o); } } @Override public boolean containsAllIterable(Iterable<?> source) { synchronized (this.lock) { return this.delegate.containsAllIterable(source); } } @Override public boolean containsAll(Collection<?> coll) { synchronized (this.lock) { return this.delegate.containsAll(coll); } } @Override public boolean containsAllArguments(Object... elements) { synchronized (this.lock) { return this.delegate.containsAllArguments(elements); } } @Override public void each(Procedure<? super T> procedure) { synchronized (this.lock) { this.delegate.forEach(procedure); } } @Override public RichIterable<T> select(Predicate<? super T> predicate) { synchronized (this.lock) { return this.delegate.select(predicate); } } @Override public <R extends Collection<T>> R select(Predicate<? super T> predicate, R target) { synchronized (this.lock) { return this.delegate.select(predicate, target); } } @Override public <P> RichIterable<T> selectWith(Predicate2<? super T, ? super P> predicate, P parameter) { synchronized (this.lock) { return this.delegate.selectWith(predicate, parameter); } } @Override public <P, R extends Collection<T>> R selectWith( Predicate2<? super T, ? super P> predicate, P parameter, R targetCollection) { synchronized (this.lock) { return this.delegate.selectWith(predicate, parameter, targetCollection); } } @Override public RichIterable<T> reject(Predicate<? super T> predicate) { synchronized (this.lock) { return this.delegate.reject(predicate); } } @Override public <P> RichIterable<T> rejectWith(Predicate2<? super T, ? super P> predicate, P parameter) { synchronized (this.lock) { return this.delegate.rejectWith(predicate, parameter); } } @Override public <R extends Collection<T>> R reject(Predicate<? super T> predicate, R target) { synchronized (this.lock) { return this.delegate.reject(predicate, target); } } @Override public <P, R extends Collection<T>> R rejectWith( Predicate2<? super T, ? super P> predicate, P parameter, R targetCollection) { synchronized (this.lock) { return this.delegate.rejectWith(predicate, parameter, targetCollection); } } @Override public PartitionIterable<T> partition(Predicate<? super T> predicate) { synchronized (this.lock) { return this.delegate.partition(predicate); } } @Override public <P> PartitionIterable<T> partitionWith(Predicate2<? super T, ? super P> predicate, P parameter) { synchronized (this.lock) { return this.delegate.partitionWith(predicate, parameter); } } @Override public <S> RichIterable<S> selectInstancesOf(Class<S> clazz) { synchronized (this.lock) { return this.delegate.selectInstancesOf(clazz); } } @Override public <V> RichIterable<V> collect(Function<? super T, ? extends V> function) { synchronized (this.lock) { return this.delegate.collect(function); } } @Override public BooleanIterable collectBoolean(BooleanFunction<? super T> booleanFunction) { synchronized (this.lock) { return this.delegate.collectBoolean(booleanFunction); } } @Override public <R extends MutableBooleanCollection> R collectBoolean(BooleanFunction<? super T> booleanFunction, R target) { synchronized (this.lock) { return this.delegate.collectBoolean(booleanFunction, target); } } @Override public <R extends MutableByteCollection> R collectByte(ByteFunction<? super T> byteFunction, R target) { synchronized (this.lock) { return this.delegate.collectByte(byteFunction, target); } } @Override public <R extends MutableCharCollection> R collectChar(CharFunction<? super T> charFunction, R target) { synchronized (this.lock) { return this.delegate.collectChar(charFunction, target); } } @Override public <R extends MutableDoubleCollection> R collectDouble(DoubleFunction<? super T> doubleFunction, R target) { synchronized (this.lock) { return this.delegate.collectDouble(doubleFunction, target); } } @Override public <R extends MutableFloatCollection> R collectFloat(FloatFunction<? super T> floatFunction, R target) { synchronized (this.lock) { return this.delegate.collectFloat(floatFunction, target); } } @Override public <R extends MutableIntCollection> R collectInt(IntFunction<? super T> intFunction, R target) { synchronized (this.lock) { return this.delegate.collectInt(intFunction, target); } } @Override public <R extends MutableLongCollection> R collectLong(LongFunction<? super T> longFunction, R target) { synchronized (this.lock) { return this.delegate.collectLong(longFunction, target); } } @Override public <R extends MutableShortCollection> R collectShort(ShortFunction<? super T> shortFunction, R target) { synchronized (this.lock) { return this.delegate.collectShort(shortFunction, target); } } @Override public <V, R extends Collection<V>> R collect(Function<? super T, ? extends V> function, R target) { synchronized (this.lock) { return this.delegate.collect(function, target); } } @Override public <P, A, R extends Collection<A>> R collectWith( Function2<? super T, ? super P, ? extends A> function, P parameter, R targetCollection) { synchronized (this.lock) { return this.delegate.collectWith(function, parameter, targetCollection); } } @Override public <V, R extends Collection<V>> R collectIf( Predicate<? super T> predicate, Function<? super T, ? extends V> function, R target) { synchronized (this.lock) { return this.delegate.collectIf(predicate, function, target); } } @Override public <V, R extends Collection<V>> R flatCollect(Function<? super T, ? extends Iterable<V>> function, R target) { synchronized (this.lock) { return this.delegate.flatCollect(function, target); } } @Override public T detect(Predicate<? super T> predicate) { synchronized (this.lock) { return this.delegate.detect(predicate); } } @Override public <P> T detectWith(Predicate2<? super T, ? super P> predicate, P parameter) { synchronized (this.lock) { return this.delegate.detectWith(predicate, parameter); } } @Override public Optional<T> detectOptional(Predicate<? super T> predicate) { synchronized (this.lock) { return this.delegate.detectOptional(predicate); } } @Override public <P> Optional<T> detectWithOptional(Predicate2<? super T, ? super P> predicate, P parameter) { synchronized (this.lock) { return this.delegate.detectWithOptional(predicate, parameter); } } @Override public T detectIfNone(Predicate<? super T> predicate, Function0<? extends T> function) { synchronized (this.lock) { return this.delegate.detectIfNone(predicate, function); } } @Override public <P> T detectWithIfNone( Predicate2<? super T, ? super P> predicate, P parameter, Function0<? extends T> function) { synchronized (this.lock) { return this.delegate.detectWithIfNone(predicate, parameter, function); } } @Override public int count(Predicate<? super T> predicate) { synchronized (this.lock) { return this.delegate.count(predicate); } } @Override public <P> int countWith(Predicate2<? super T, ? super P> predicate, P parameter) { synchronized (this.lock) { return this.delegate.countWith(predicate, parameter); } } @Override public boolean anySatisfy(Predicate<? super T> predicate) { synchronized (this.lock) { return this.delegate.anySatisfy(predicate); } } @Override public <P> boolean anySatisfyWith(Predicate2<? super T, ? super P> predicate, P parameter) { synchronized (this.lock) { return this.delegate.anySatisfyWith(predicate, parameter); } } @Override public boolean allSatisfy(Predicate<? super T> predicate) { synchronized (this.lock) { return this.delegate.allSatisfy(predicate); } } @Override public <P> boolean allSatisfyWith(Predicate2<? super T, ? super P> predicate, P parameter) { synchronized (this.lock) { return this.delegate.allSatisfyWith(predicate, parameter); } } @Override public boolean noneSatisfy(Predicate<? super T> predicate) { synchronized (this.lock) { return this.delegate.noneSatisfy(predicate); } } @Override public <P> boolean noneSatisfyWith(Predicate2<? super T, ? super P> predicate, P parameter) { synchronized (this.lock) { return this.delegate.noneSatisfyWith(predicate, parameter); } } @Override public <IV> IV injectInto(IV injectedValue, Function2<? super IV, ? super T, ? extends IV> function) { synchronized (this.lock) { return this.delegate.injectInto(injectedValue, function); } } @Override public int injectInto(int injectedValue, IntObjectToIntFunction<? super T> function) { synchronized (this.lock) { return this.delegate.injectInto(injectedValue, function); } } @Override public long injectInto(long injectedValue, LongObjectToLongFunction<? super T> function) { synchronized (this.lock) { return this.delegate.injectInto(injectedValue, function); } } @Override public float injectInto(float injectedValue, FloatObjectToFloatFunction<? super T> function) { synchronized (this.lock) { return this.delegate.injectInto(injectedValue, function); } } @Override public double injectInto(double injectedValue, DoubleObjectToDoubleFunction<? super T> function) { synchronized (this.lock) { return this.delegate.injectInto(injectedValue, function); } } @Override public <R extends Collection<T>> R into(R target) { synchronized (this.lock) { return this.delegate.into(target); } } @Override public MutableList<T> toList() { synchronized (this.lock) { return this.delegate.toList(); } } @Override public MutableList<T> toSortedList() { synchronized (this.lock) { return this.delegate.toSortedList(); } } @Override public MutableList<T> toSortedList(Comparator<? super T> comparator) { synchronized (this.lock) { return this.delegate.toSortedList(comparator); } } @Override public <V extends Comparable<? super V>> MutableList<T> toSortedListBy(Function<? super T, ? extends V> function) { synchronized (this.lock) { return this.delegate.toSortedList(Comparators.byFunction(function)); } } @Override public MutableSet<T> toSet() { synchronized (this.lock) { return this.delegate.toSet(); } } @Override public MutableSortedSet<T> toSortedSet() { synchronized (this.lock) { return this.delegate.toSortedSet(); } } @Override public MutableSortedSet<T> toSortedSet(Comparator<? super T> comparator) { synchronized (this.lock) { return this.delegate.toSortedSet(comparator); } } @Override public <V extends Comparable<? super V>> MutableSortedSet<T> toSortedSetBy(Function<? super T, ? extends V> function) { synchronized (this.lock) { return this.delegate.toSortedSetBy(function); } } @Override public MutableBag<T> toBag() { synchronized (this.lock) { return this.delegate.toBag(); } } @Override public MutableSortedBag<T> toSortedBag() { synchronized (this.lock) { return this.delegate.toSortedBag(); } } @Override public MutableSortedBag<T> toSortedBag(Comparator<? super T> comparator) { synchronized (this.lock) { return this.delegate.toSortedBag(comparator); } } @Override public <V extends Comparable<? super V>> MutableSortedBag<T> toSortedBagBy(Function<? super T, ? extends V> function) { synchronized (this.lock) { return this.delegate.toSortedBag(Comparators.byFunction(function)); } } @Override public <NK, NV> MutableMap<NK, NV> toMap( Function<? super T, ? extends NK> keyFunction, Function<? super T, ? extends NV> valueFunction) { synchronized (this.lock) { return this.delegate.toMap(keyFunction, valueFunction); } } @Override public <K, V, R extends Map<K, V>> R toMap( Function<? super T, ? extends K> keyFunction, Function<? super T, ? extends V> valueFunction, R target) { synchronized (this.lock) { return this.delegate.toMap(keyFunction, valueFunction, target); } } @Override public <NK, NV> MutableSortedMap<NK, NV> toSortedMap( Function<? super T, ? extends NK> keyFunction, Function<? super T, ? extends NV> valueFunction) { synchronized (this.lock) { return this.delegate.toSortedMap(keyFunction, valueFunction); } } @Override public <NK, NV> MutableSortedMap<NK, NV> toSortedMap( Comparator<? super NK> comparator, Function<? super T, ? extends NK> keyFunction, Function<? super T, ? extends NV> valueFunction) { synchronized (this.lock) { return this.delegate.toSortedMap(comparator, keyFunction, valueFunction); } } @Override public <KK extends Comparable<? super KK>, NK, NV> MutableSortedMap<NK, NV> toSortedMapBy( Function<? super NK, KK> sortBy, Function<? super T, ? extends NK> keyFunction, Function<? super T, ? extends NV> valueFunction) { synchronized (this.lock) { return this.delegate.toSortedMapBy(sortBy, keyFunction, valueFunction); } } @Override public <NK, NV> MutableBiMap<NK, NV> toBiMap( Function<? super T, ? extends NK> keyFunction, Function<? super T, ? extends NV> valueFunction) { synchronized (this.lock) { return this.delegate.toBiMap(keyFunction, valueFunction); } } @Override public LazyIterable<T> asLazy() { return LazyIterate.adapt(this); } @Override public Object[] toArray() { synchronized (this.lock) { return this.delegate.toArray(); } } @Override public <T> T[] toArray(T[] a) { synchronized (this.lock) { return this.delegate.toArray(a); } } @Override public T min(Comparator<? super T> comparator) { synchronized (this.lock) { return this.delegate.min(comparator); } } @Override public T max(Comparator<? super T> comparator) { synchronized (this.lock) { return this.delegate.max(comparator); } } @Override public Optional<T> minOptional(Comparator<? super T> comparator) { synchronized (this.lock) { return this.delegate.minOptional(comparator); } } @Override public Optional<T> maxOptional(Comparator<? super T> comparator) { synchronized (this.lock) { return this.delegate.maxOptional(comparator); } } @Override public T min() { synchronized (this.lock) { return this.delegate.min(); } } @Override public T max() { synchronized (this.lock) { return this.delegate.max(); } } @Override public Optional<T> minOptional() { synchronized (this.lock) { return this.delegate.minOptional(); } } @Override public Optional<T> maxOptional() { synchronized (this.lock) { return this.delegate.maxOptional(); } } @Override public <V extends Comparable<? super V>> T minBy(Function<? super T, ? extends V> function) { synchronized (this.lock) { return this.delegate.minBy(function); } } @Override public <V extends Comparable<? super V>> T maxBy(Function<? super T, ? extends V> function) { synchronized (this.lock) { return this.delegate.maxBy(function); } } @Override public <V extends Comparable<? super V>> Optional<T> minByOptional(Function<? super T, ? extends V> function) { synchronized (this.lock) { return this.delegate.minByOptional(function); } } @Override public <V extends Comparable<? super V>> Optional<T> maxByOptional(Function<? super T, ? extends V> function) { synchronized (this.lock) { return this.delegate.maxByOptional(function); } } @Override public long sumOfInt(IntFunction<? super T> function) { synchronized (this.lock) { return this.delegate.sumOfInt(function); } } @Override public double sumOfFloat(FloatFunction<? super T> function) { synchronized (this.lock) { return this.delegate.sumOfFloat(function); } } @Override public long sumOfLong(LongFunction<? super T> function) { synchronized (this.lock) { return this.delegate.sumOfLong(function); } } @Override public double sumOfDouble(DoubleFunction<? super T> function) { synchronized (this.lock) { return this.delegate.sumOfDouble(function); } } @Override public String makeString() { synchronized (this.lock) { return this.delegate.makeString(); } } @Override public String makeString(String separator) { synchronized (this.lock) { return this.delegate.makeString(separator); } } @Override public String makeString(String start, String separator, String end) { synchronized (this.lock) { return this.delegate.makeString(start, separator, end); } } @Override public void appendString(Appendable appendable) { synchronized (this.lock) { this.delegate.appendString(appendable); } } @Override public void appendString(Appendable appendable, String separator) { synchronized (this.lock) { this.delegate.appendString(appendable, separator); } } @Override public void appendString(Appendable appendable, String start, String separator, String end) { synchronized (this.lock) { this.delegate.appendString(appendable, start, separator, end); } }
Since:9.0
/** * @since 9.0 */
@Override public <V> Bag<V> countBy(Function<? super T, ? extends V> function) { synchronized (this.lock) { return this.getDelegate().countBy(function); } }
Since:9.0
/** * @since 9.0 */
@Override public <V, R extends MutableBagIterable<V>> R countBy(Function<? super T, ? extends V> function, R target) { synchronized (this.lock) { return this.delegate.countBy(function, target); } }
Since:9.0
/** * @since 9.0 */
@Override public <V, P> Bag<V> countByWith(Function2<? super T, ? super P, ? extends V> function, P parameter) { synchronized (this.lock) { return this.delegate.countByWith(function, parameter); } }
Since:9.0
/** * @since 9.0 */
@Override public <V, P, R extends MutableBagIterable<V>> R countByWith(Function2<? super T, ? super P, ? extends V> function, P parameter, R target) { synchronized (this.lock) { return this.delegate.countByWith(function, parameter, target); } }
Since:10.0.0
/** * @since 10.0.0 */
@Override public <V> Bag<V> countByEach(Function<? super T, ? extends Iterable<V>> function) { synchronized (this.lock) { return this.delegate.countByEach(function); } }
Since:10.0.0
/** * @since 10.0.0 */
@Override public <V, R extends MutableBagIterable<V>> R countByEach(Function<? super T, ? extends Iterable<V>> function, R target) { synchronized (this.lock) { return this.delegate.countByEach(function, target); } } @Override public <V, R extends MutableMultimap<V, T>> R groupBy( Function<? super T, ? extends V> function, R target) { synchronized (this.lock) { return this.delegate.groupBy(function, target); } } @Override public <V, R extends MutableMultimap<V, T>> R groupByEach( Function<? super T, ? extends Iterable<V>> function, R target) { synchronized (this.lock) { return this.delegate.groupByEach(function, target); } } @Override public <V> MapIterable<V, T> groupByUniqueKey(Function<? super T, ? extends V> function) { synchronized (this.lock) { return this.delegate.groupByUniqueKey(function, UnifiedMap.newMap(this.size())); } } @Override public <V, R extends MutableMapIterable<V, T>> R groupByUniqueKey( Function<? super T, ? extends V> function, R target) { synchronized (this.lock) { return this.delegate.groupByUniqueKey(function, target); } } @Override public <S, R extends Collection<Pair<T, S>>> R zip(Iterable<S> that, R target) { synchronized (this.lock) { return this.delegate.zip(that, target); } } @Override public <R extends Collection<Pair<T, Integer>>> R zipWithIndex(R target) { synchronized (this.lock) { return this.delegate.zipWithIndex(target); } } @Override public RichIterable<RichIterable<T>> chunk(int size) { synchronized (this.lock) { return this.delegate.chunk(size); } } @Override public T getOnly() { synchronized (this.lock) { return this.delegate.getOnly(); } } @Override public ByteIterable collectByte(ByteFunction<? super T> byteFunction) { synchronized (this.lock) { return this.delegate.collectByte(byteFunction); } } @Override public CharIterable collectChar(CharFunction<? super T> charFunction) { synchronized (this.lock) { return this.delegate.collectChar(charFunction); } } @Override public DoubleIterable collectDouble(DoubleFunction<? super T> doubleFunction) { synchronized (this.lock) { return this.delegate.collectDouble(doubleFunction); } } @Override public FloatIterable collectFloat(FloatFunction<? super T> floatFunction) { synchronized (this.lock) { return this.delegate.collectFloat(floatFunction); } } @Override public IntIterable collectInt(IntFunction<? super T> intFunction) { synchronized (this.lock) { return this.delegate.collectInt(intFunction); } } @Override public LongIterable collectLong(LongFunction<? super T> longFunction) { synchronized (this.lock) { return this.delegate.collectLong(longFunction); } } @Override public ShortIterable collectShort(ShortFunction<? super T> shortFunction) { synchronized (this.lock) { return this.delegate.collectShort(shortFunction); } } @Override public <P, V> RichIterable<V> collectWith(Function2<? super T, ? super P, ? extends V> function, P parameter) { synchronized (this.lock) { return this.delegate.collectWith(function, parameter); } } @Override public <V> RichIterable<V> collectIf(Predicate<? super T> predicate, Function<? super T, ? extends V> function) { synchronized (this.lock) { return this.delegate.collectIf(predicate, function); } } @Override public <V> RichIterable<V> flatCollect(Function<? super T, ? extends Iterable<V>> function) { synchronized (this.lock) { return this.delegate.flatCollect(function); } } @Override public <V> ObjectLongMap<V> sumByInt(Function<? super T, ? extends V> groupBy, IntFunction<? super T> function) { synchronized (this.lock) { return this.delegate.sumByInt(groupBy, function); } } @Override public <V> ObjectDoubleMap<V> sumByFloat(Function<? super T, ? extends V> groupBy, FloatFunction<? super T> function) { synchronized (this.lock) { return this.delegate.sumByFloat(groupBy, function); } } @Override public <V> ObjectLongMap<V> sumByLong(Function<? super T, ? extends V> groupBy, LongFunction<? super T> function) { synchronized (this.lock) { return this.delegate.sumByLong(groupBy, function); } } @Override public <V> ObjectDoubleMap<V> sumByDouble(Function<? super T, ? extends V> groupBy, DoubleFunction<? super T> function) { synchronized (this.lock) { return this.delegate.sumByDouble(groupBy, function); } } @Override public <V> Multimap<V, T> groupBy(Function<? super T, ? extends V> function) { synchronized (this.lock) { return this.delegate.groupBy(function); } } @Override public <V> Multimap<V, T> groupByEach(Function<? super T, ? extends Iterable<V>> function) { synchronized (this.lock) { return this.delegate.groupByEach(function); } } @Override public <S> RichIterable<Pair<T, S>> zip(Iterable<S> that) { synchronized (this.lock) { return this.delegate.zip(that); } } @Override public RichIterable<Pair<T, Integer>> zipWithIndex() { synchronized (this.lock) { return this.delegate.zipWithIndex(); } } @Override public <K, V> MapIterable<K, V> aggregateInPlaceBy(Function<? super T, ? extends K> groupBy, Function0<? extends V> zeroValueFactory, Procedure2<? super V, ? super T> mutatingAggregator) { synchronized (this.lock) { return this.delegate.aggregateInPlaceBy(groupBy, zeroValueFactory, mutatingAggregator); } } @Override public <K, V> MapIterable<K, V> aggregateBy(Function<? super T, ? extends K> groupBy, Function0<? extends V> zeroValueFactory, Function2<? super V, ? super T, ? extends V> nonMutatingAggregator) { synchronized (this.lock) { return this.delegate.aggregateBy(groupBy, zeroValueFactory, nonMutatingAggregator); } } @Override public RichIterable<T> tap(Procedure<? super T> procedure) { synchronized (this.lock) { this.forEach(procedure); return this; } } }