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

com.gs.collections.impl.UnmodifiableRichIterable 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;

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

import com.gs.collections.api.BooleanIterable;
import com.gs.collections.api.ByteIterable;
import com.gs.collections.api.CharIterable;
import com.gs.collections.api.DoubleIterable;
import com.gs.collections.api.FloatIterable;
import com.gs.collections.api.IntIterable;
import com.gs.collections.api.LazyIterable;
import com.gs.collections.api.LongIterable;
import com.gs.collections.api.RichIterable;
import com.gs.collections.api.ShortIterable;
import com.gs.collections.api.bag.MutableBag;
import com.gs.collections.api.bag.sorted.MutableSortedBag;
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.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.procedure.Procedure;
import com.gs.collections.api.block.procedure.Procedure2;
import com.gs.collections.api.block.procedure.primitive.ObjectIntProcedure;
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.MapIterable;
import com.gs.collections.api.map.MutableMap;
import com.gs.collections.api.map.primitive.ObjectDoubleMap;
import com.gs.collections.api.map.primitive.ObjectLongMap;
import com.gs.collections.api.map.sorted.MutableSortedMap;
import com.gs.collections.api.multimap.Multimap;
import com.gs.collections.api.multimap.MutableMultimap;
import com.gs.collections.api.partition.PartitionIterable;
import com.gs.collections.api.set.MutableSet;
import com.gs.collections.api.set.sorted.MutableSortedSet;
import com.gs.collections.api.tuple.Pair;

/**
 * An unmodifiable view of a RichIterable.
 */
public class UnmodifiableRichIterable
        implements RichIterable, Serializable
{
    private static final long serialVersionUID = 1L;

    protected final RichIterable iterable;

    protected UnmodifiableRichIterable(RichIterable richIterable)
    {
        this.iterable = richIterable;
    }

    /**
     * This method will take a RichIterable and wrap it directly in a UnmodifiableRichIterable.
     */
    public static > UnmodifiableRichIterable of(RI iterable)
    {
        if (iterable == null)
        {
            throw new IllegalArgumentException("cannot create a UnmodifiableRichIterable for null");
        }
        return new UnmodifiableRichIterable(iterable);
    }

    public > R select(Predicate predicate, R target)
    {
        return this.iterable.select(predicate, target);
    }

    public 

RichIterable selectWith(Predicate2 predicate, P parameter) { return this.iterable.selectWith(predicate, parameter); } public > R selectWith(Predicate2 predicate, P parameter, R targetCollection) { return this.iterable.selectWith(predicate, parameter, targetCollection); } public > R reject(Predicate predicate, R target) { return this.iterable.reject(predicate, target); } public

RichIterable rejectWith(Predicate2 predicate, P parameter) { return this.iterable.rejectWith(predicate, parameter); } public > R rejectWith(Predicate2 predicate, P parameter, R targetCollection) { return this.iterable.rejectWith(predicate, parameter, targetCollection); } public PartitionIterable partition(Predicate predicate) { return this.iterable.partition(predicate); } public

PartitionIterable partitionWith(Predicate2 predicate, P parameter) { return this.iterable.partitionWith(predicate, parameter); } public > R collect(Function function, R target) { return this.iterable.collect(function, target); } public RichIterable collectWith(Function2 function, P parameter) { return this.iterable.collectWith(function, parameter); } public > R collectWith(Function2 function, P parameter, R targetCollection) { return this.iterable.collectWith(function, parameter, targetCollection); } public > R collectIf(Predicate predicate, Function function, R target) { return this.iterable.collectIf(predicate, function, target); } public > R flatCollect(Function> function, R target) { return this.iterable.flatCollect(function, target); } public boolean contains(Object object) { return this.iterable.contains(object); } public boolean containsAllIterable(Iterable source) { return this.iterable.containsAllIterable(source); } public boolean containsAll(Collection source) { return this.iterable.containsAll(source); } public boolean containsAllArguments(Object... elements) { return this.iterable.containsAllArguments(elements); } public Object[] toArray() { return this.iterable.toArray(); } public T[] toArray(T[] a) { return this.iterable.toArray(a); } public RichIterable tap(Procedure procedure) { this.forEach(procedure); return this; } public void forEach(Procedure procedure) { this.each(procedure); } public void each(Procedure procedure) { this.iterable.forEach(procedure); } public void forEachWithIndex(ObjectIntProcedure objectIntProcedure) { this.iterable.forEachWithIndex(objectIntProcedure); } public

void forEachWith(Procedure2 procedure, P parameter) { this.iterable.forEachWith(procedure, parameter); } public boolean notEmpty() { return this.iterable.notEmpty(); } public boolean isEmpty() { return this.iterable.isEmpty(); } public int size() { return this.iterable.size(); } public T getFirst() { return this.iterable.getFirst(); } public T getLast() { return this.iterable.getLast(); } public RichIterable select(Predicate predicate) { return this.iterable.select(predicate); } public RichIterable reject(Predicate predicate) { return this.iterable.reject(predicate); } public RichIterable selectInstancesOf(Class clazz) { return this.iterable.selectInstancesOf(clazz); } public RichIterable collect(Function function) { return this.iterable.collect(function); } public BooleanIterable collectBoolean(BooleanFunction booleanFunction) { return this.iterable.collectBoolean(booleanFunction); } public R collectBoolean(BooleanFunction booleanFunction, R target) { return this.iterable.collectBoolean(booleanFunction, target); } public ByteIterable collectByte(ByteFunction byteFunction) { return this.iterable.collectByte(byteFunction); } public R collectByte(ByteFunction byteFunction, R target) { return this.iterable.collectByte(byteFunction, target); } public CharIterable collectChar(CharFunction charFunction) { return this.iterable.collectChar(charFunction); } public R collectChar(CharFunction charFunction, R target) { return this.iterable.collectChar(charFunction, target); } public DoubleIterable collectDouble(DoubleFunction doubleFunction) { return this.iterable.collectDouble(doubleFunction); } public R collectDouble(DoubleFunction doubleFunction, R target) { return this.iterable.collectDouble(doubleFunction, target); } public FloatIterable collectFloat(FloatFunction floatFunction) { return this.iterable.collectFloat(floatFunction); } public R collectFloat(FloatFunction floatFunction, R target) { return this.iterable.collectFloat(floatFunction, target); } public IntIterable collectInt(IntFunction intFunction) { return this.iterable.collectInt(intFunction); } public R collectInt(IntFunction intFunction, R target) { return this.iterable.collectInt(intFunction, target); } public LongIterable collectLong(LongFunction longFunction) { return this.iterable.collectLong(longFunction); } public R collectLong(LongFunction longFunction, R target) { return this.iterable.collectLong(longFunction, target); } public ShortIterable collectShort(ShortFunction shortFunction) { return this.iterable.collectShort(shortFunction); } public R collectShort(ShortFunction shortFunction, R target) { return this.iterable.collectShort(shortFunction, target); } public RichIterable flatCollect(Function> function) { return this.iterable.flatCollect(function); } public RichIterable collectIf(Predicate predicate, Function function) { return this.iterable.collectIf(predicate, function); } public T detect(Predicate predicate) { return this.iterable.detect(predicate); } public

T detectWith(Predicate2 predicate, P parameter) { return this.iterable.detectWith(predicate, parameter); } public T min(Comparator comparator) { return this.iterable.min(comparator); } public T max(Comparator comparator) { return this.iterable.max(comparator); } public T min() { return this.iterable.min(); } public T max() { return this.iterable.max(); } public > T minBy(Function function) { return this.iterable.minBy(function); } public > T maxBy(Function function) { return this.iterable.maxBy(function); } public T detectIfNone(Predicate predicate, Function0 function) { return this.iterable.detectIfNone(predicate, function); } public

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

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

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

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

boolean noneSatisfyWith(Predicate2 predicate, P parameter) { return this.iterable.noneSatisfyWith(predicate, parameter); } public IV injectInto(IV injectedValue, Function2 function) { return this.iterable.injectInto(injectedValue, function); } public int injectInto(int injectedValue, IntObjectToIntFunction function) { return this.iterable.injectInto(injectedValue, function); } public long injectInto(long injectedValue, LongObjectToLongFunction function) { return this.iterable.injectInto(injectedValue, function); } public double injectInto(double injectedValue, DoubleObjectToDoubleFunction function) { return this.iterable.injectInto(injectedValue, function); } public float injectInto(float injectedValue, FloatObjectToFloatFunction function) { return this.iterable.injectInto(injectedValue, function); } public long sumOfInt(IntFunction function) { return this.iterable.sumOfInt(function); } public double sumOfFloat(FloatFunction function) { return this.iterable.sumOfFloat(function); } public long sumOfLong(LongFunction function) { return this.iterable.sumOfLong(function); } public double sumOfDouble(DoubleFunction function) { return this.iterable.sumOfDouble(function); } public ObjectLongMap sumByInt(Function groupBy, IntFunction function) { return this.iterable.sumByInt(groupBy, function); } public ObjectDoubleMap sumByFloat(Function groupBy, FloatFunction function) { return this.iterable.sumByFloat(groupBy, function); } public ObjectLongMap sumByLong(Function groupBy, LongFunction function) { return this.iterable.sumByLong(groupBy, function); } public ObjectDoubleMap sumByDouble(Function groupBy, DoubleFunction function) { return this.iterable.sumByDouble(groupBy, function); } public MutableList toList() { return this.iterable.toList(); } public MutableList toSortedList() { return this.iterable.toSortedList(); } public MutableList toSortedList(Comparator comparator) { return this.iterable.toSortedList(comparator); } public > MutableList toSortedListBy(Function function) { return this.iterable.toSortedListBy(function); } public MutableSortedSet toSortedSet() { return this.iterable.toSortedSet(); } public MutableSortedSet toSortedSet(Comparator comparator) { return this.iterable.toSortedSet(comparator); } public > MutableSortedSet toSortedSetBy(Function function) { return this.iterable.toSortedSetBy(function); } public MutableSet toSet() { return this.iterable.toSet(); } public MutableBag toBag() { return this.iterable.toBag(); } public MutableSortedBag toSortedBag() { return this.iterable.toSortedBag(); } public MutableSortedBag toSortedBag(Comparator comparator) { return this.iterable.toSortedBag(comparator); } public > MutableSortedBag toSortedBagBy(Function function) { return this.iterable.toSortedBagBy(function); } public MutableMap toMap( Function keyFunction, Function valueFunction) { return this.iterable.toMap(keyFunction, valueFunction); } public MutableSortedMap toSortedMap( Function keyFunction, Function valueFunction) { return this.iterable.toSortedMap(keyFunction, valueFunction); } public MutableSortedMap toSortedMap(Comparator comparator, Function keyFunction, Function valueFunction) { return this.iterable.toSortedMap(comparator, keyFunction, valueFunction); } public LazyIterable asLazy() { return this.iterable.asLazy(); } public Iterator iterator() { return new UnmodifiableIteratorAdapter(this.iterable.iterator()); } @Override public String toString() { return this.iterable.toString(); } public String makeString() { return this.iterable.makeString(); } public String makeString(String separator) { return this.iterable.makeString(separator); } public String makeString(String start, String separator, String end) { return this.iterable.makeString(start, separator, end); } public void appendString(Appendable appendable) { this.iterable.appendString(appendable); } public void appendString(Appendable appendable, String separator) { this.iterable.appendString(appendable, separator); } public void appendString(Appendable appendable, String start, String separator, String end) { this.iterable.appendString(appendable, start, separator, end); } public Multimap groupBy(Function function) { return this.iterable.groupBy(function); } public > R groupBy( Function function, R target) { return this.iterable.groupBy(function, target); } public Multimap groupByEach(Function> function) { return this.iterable.groupByEach(function); } public > R groupByEach( Function> function, R target) { return this.iterable.groupByEach(function, target); } public MapIterable groupByUniqueKey(Function function) { return this.iterable.groupByUniqueKey(function); } public > R groupByUniqueKey( Function function, R target) { return this.iterable.groupByUniqueKey(function, target); } public RichIterable> zip(Iterable that) { return this.iterable.zip(that); } public >> R zip(Iterable that, R target) { return this.iterable.zip(that, target); } public RichIterable> zipWithIndex() { return this.iterable.zipWithIndex(); } public >> R zipWithIndex(R target) { return this.iterable.zipWithIndex(target); } public RichIterable> chunk(int size) { return this.iterable.chunk(size); } public MapIterable aggregateInPlaceBy(Function groupBy, Function0 zeroValueFactory, Procedure2 mutatingAggregator) { return this.iterable.aggregateInPlaceBy(groupBy, zeroValueFactory, mutatingAggregator); } public MapIterable aggregateBy(Function groupBy, Function0 zeroValueFactory, Function2 nonMutatingAggregator) { return this.iterable.aggregateBy(groupBy, zeroValueFactory, nonMutatingAggregator); } }