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

org.eclipse.collections.impl.UnmodifiableRichIterable Maven / Gradle / Ivy

There is a newer version: 12.0.0.M3
Show newest version
/*
 * Copyright (c) 2020 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;

import java.io.Serializable;
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.MutableBag;
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;

/**
 * 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);
    }

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

    @Override
    public 

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

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

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

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

T detectWith(Predicate2 predicate, P parameter) { return this.iterable.detectWith(predicate, parameter); } @Override public Optional detectOptional(Predicate predicate) { return this.iterable.detectOptional(predicate); } @Override public

Optional detectWithOptional(Predicate2 predicate, P parameter) { return this.iterable.detectWithOptional(predicate, parameter); } @Override public T detectIfNone(Predicate predicate, Function0 function) { return this.iterable.detectIfNone(predicate, function); } @Override public

T detectWithIfNone(Predicate2 predicate, P parameter, Function0 function) { return this.iterable.detectWithIfNone(predicate, parameter, function); } @Override public T min(Comparator comparator) { return this.iterable.min(comparator); } @Override public T max(Comparator comparator) { return this.iterable.max(comparator); } @Override public T min() { return this.iterable.min(); } @Override public T max() { return this.iterable.max(); } @Override public > T minBy(Function function) { return this.iterable.minBy(function); } @Override public > T maxBy(Function function) { return this.iterable.maxBy(function); } @Override public int count(Predicate predicate) { return this.iterable.count(predicate); } @Override public

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

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

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

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