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

com.gs.collections.impl.collection.mutable.AbstractSynchronizedMutableCollection 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 2015 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.collection.mutable;

import java.util.Collection;

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.Function3;
import com.gs.collections.api.block.predicate.Predicate;
import com.gs.collections.api.block.predicate.Predicate2;
import com.gs.collections.api.block.procedure.Procedure2;
import com.gs.collections.api.collection.MutableCollection;
import com.gs.collections.api.list.MutableList;
import com.gs.collections.api.map.MutableMap;
import com.gs.collections.api.tuple.Twin;
import com.gs.collections.impl.collection.AbstractSynchronizedRichIterable;
import net.jcip.annotations.ThreadSafe;

@ThreadSafe
public abstract class AbstractSynchronizedMutableCollection extends AbstractSynchronizedRichIterable implements MutableCollection
{
    protected AbstractSynchronizedMutableCollection(MutableCollection delegate)
    {
        this(delegate, null);
    }

    protected AbstractSynchronizedMutableCollection(MutableCollection delegate, Object lock)
    {
        super(delegate, lock);
    }

    @Override
    protected MutableCollection getDelegate()
    {
        return (MutableCollection) super.getDelegate();
    }

    public boolean add(T o)
    {
        synchronized (this.getLock())
        {
            return this.getDelegate().add(o);
        }
    }

    public boolean remove(Object o)
    {
        synchronized (this.getLock())
        {
            return this.getDelegate().remove(o);
        }
    }

    public boolean addAll(Collection coll)
    {
        synchronized (this.getLock())
        {
            return this.getDelegate().addAll(coll);
        }
    }

    public boolean removeAll(Collection coll)
    {
        synchronized (this.getLock())
        {
            return this.getDelegate().removeAll(coll);
        }
    }

    public boolean retainAll(Collection coll)
    {
        synchronized (this.getLock())
        {
            return this.getDelegate().retainAll(coll);
        }
    }

    public void clear()
    {
        synchronized (this.getLock())
        {
            this.getDelegate().clear();
        }
    }

    public boolean removeIf(Predicate predicate)
    {
        synchronized (this.lock)
        {
            return this.getDelegate().removeIf(predicate);
        }
    }

    public 

boolean removeIfWith(Predicate2 predicate, P parameter) { synchronized (this.lock) { return this.getDelegate().removeIfWith(predicate, parameter); } } public boolean addAllIterable(Iterable iterable) { synchronized (this.getLock()) { return this.getDelegate().addAllIterable(iterable); } } public boolean removeAllIterable(Iterable iterable) { synchronized (this.getLock()) { return this.getDelegate().removeAllIterable(iterable); } } public boolean retainAllIterable(Iterable iterable) { synchronized (this.getLock()) { return this.getDelegate().retainAllIterable(iterable); } } public

Twin> selectAndRejectWith( Predicate2 predicate, P parameter) { synchronized (this.lock) { return this.getDelegate().selectAndRejectWith(predicate, parameter); } } public IV injectIntoWith( IV injectValue, Function3 function, P parameter) { synchronized (this.lock) { return this.getDelegate().injectIntoWith(injectValue, function, parameter); } } public MutableMap aggregateInPlaceBy( Function groupBy, Function0 zeroValueFactory, Procedure2 mutatingAggregator) { synchronized (this.getLock()) { return this.getDelegate().aggregateInPlaceBy(groupBy, zeroValueFactory, mutatingAggregator); } } public MutableMap aggregateBy( Function groupBy, Function0 zeroValueFactory, Function2 nonMutatingAggregator) { synchronized (this.getLock()) { return this.getDelegate().aggregateBy(groupBy, zeroValueFactory, nonMutatingAggregator); } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy