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

org.eclipse.collections.impl.stack.mutable.UnmodifiableStack Maven / Gradle / Ivy

Go to download

Builds the commons-text. Requires eclipse-collections-api be built first and be excluded from any other poms requiring it.

There is a newer version: 11.1.0-r13
Show newest version
/*
 * Copyright (c) 2022 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.stack.mutable;

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.ObjectIntToObjectFunction;
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.factory.primitive.ObjectDoubleMaps;
import org.eclipse.collections.api.factory.primitive.ObjectLongMaps;
import org.eclipse.collections.api.list.ListIterable;
import org.eclipse.collections.api.list.MutableList;
import org.eclipse.collections.api.map.MutableMap;
import org.eclipse.collections.api.map.MutableMapIterable;
import org.eclipse.collections.api.map.primitive.MutableObjectDoubleMap;
import org.eclipse.collections.api.map.primitive.MutableObjectLongMap;
import org.eclipse.collections.api.map.sorted.MutableSortedMap;
import org.eclipse.collections.api.multimap.MutableMultimap;
import org.eclipse.collections.api.multimap.list.MutableListMultimap;
import org.eclipse.collections.api.ordered.OrderedIterable;
import org.eclipse.collections.api.partition.stack.PartitionMutableStack;
import org.eclipse.collections.api.set.MutableSet;
import org.eclipse.collections.api.set.sorted.MutableSortedSet;
import org.eclipse.collections.api.stack.ImmutableStack;
import org.eclipse.collections.api.stack.MutableStack;
import org.eclipse.collections.api.stack.primitive.MutableBooleanStack;
import org.eclipse.collections.api.stack.primitive.MutableByteStack;
import org.eclipse.collections.api.stack.primitive.MutableCharStack;
import org.eclipse.collections.api.stack.primitive.MutableDoubleStack;
import org.eclipse.collections.api.stack.primitive.MutableFloatStack;
import org.eclipse.collections.api.stack.primitive.MutableIntStack;
import org.eclipse.collections.api.stack.primitive.MutableLongStack;
import org.eclipse.collections.api.stack.primitive.MutableShortStack;
import org.eclipse.collections.api.tuple.Pair;
import org.eclipse.collections.impl.UnmodifiableIteratorAdapter;
import org.eclipse.collections.impl.block.factory.PrimitiveFunctions;

public final class UnmodifiableStack implements MutableStack, Serializable
{
    private static final long serialVersionUID = 1L;

    private final MutableStack mutableStack;

    UnmodifiableStack(MutableStack mutableStack)
    {
        if (mutableStack == null)
        {
            throw new IllegalArgumentException("Cannot create a UnmodifiableStack on a null stack");
        }
        this.mutableStack = mutableStack;
    }

    public static > UnmodifiableStack of(S stack)
    {
        return new UnmodifiableStack<>(stack);
    }

    @Override
    public T pop()
    {
        throw new UnsupportedOperationException("Cannot call pop() on " + this.getClass().getSimpleName());
    }

    @Override
    public ListIterable pop(int count)
    {
        throw new UnsupportedOperationException("Cannot call pop() on " + this.getClass().getSimpleName());
    }

    @Override
    public > R pop(int count, R targetCollection)
    {
        throw new UnsupportedOperationException("Cannot call pop() on " + this.getClass().getSimpleName());
    }

    @Override
    public > R pop(int count, R targetStack)
    {
        throw new UnsupportedOperationException("Cannot call pop() on " + this.getClass().getSimpleName());
    }

    @Override
    public void clear()
    {
        throw new UnsupportedOperationException("Cannot call clear() on " + this.getClass().getSimpleName());
    }

    @Override
    public void push(T item)
    {
        throw new UnsupportedOperationException("Cannot call push() on " + this.getClass().getSimpleName());
    }

    @Override
    public Iterator iterator()
    {
        return new UnmodifiableIteratorAdapter<>(this.mutableStack.iterator());
    }

    @Override
    public MutableStack select(Predicate predicate)
    {
        return this.mutableStack.select(predicate);
    }

    @Override
    public 

MutableStack selectWith(Predicate2 predicate, P parameter) { return this.mutableStack.selectWith(predicate, parameter); } @Override public MutableStack reject(Predicate predicate) { return this.mutableStack.reject(predicate); } @Override public

MutableStack rejectWith(Predicate2 predicate, P parameter) { return this.mutableStack.rejectWith(predicate, parameter); } @Override public PartitionMutableStack partition(Predicate predicate) { return this.mutableStack.partition(predicate); } @Override public

PartitionMutableStack partitionWith(Predicate2 predicate, P parameter) { return this.mutableStack.partitionWith(predicate, parameter); } @Override public MutableStack selectInstancesOf(Class clazz) { return this.mutableStack.selectInstancesOf(clazz); } @Override public MutableStack collect(Function function) { return this.mutableStack.collect(function); } @Override public MutableBooleanStack collectBoolean(BooleanFunction booleanFunction) { return this.mutableStack.collectBoolean(booleanFunction); } @Override public R collectBoolean(BooleanFunction booleanFunction, R target) { return this.mutableStack.collectBoolean(booleanFunction, target); } @Override public R flatCollectBoolean( Function function, R target) { return this.mutableStack.flatCollectBoolean(function, target); } @Override public MutableByteStack collectByte(ByteFunction byteFunction) { return this.mutableStack.collectByte(byteFunction); } @Override public R collectByte(ByteFunction byteFunction, R target) { return this.mutableStack.collectByte(byteFunction, target); } @Override public R flatCollectByte( Function function, R target) { return this.mutableStack.flatCollectByte(function, target); } @Override public MutableCharStack collectChar(CharFunction charFunction) { return this.mutableStack.collectChar(charFunction); } @Override public R collectChar(CharFunction charFunction, R target) { return this.mutableStack.collectChar(charFunction, target); } @Override public R flatCollectChar( Function function, R target) { return this.mutableStack.flatCollectChar(function, target); } @Override public MutableDoubleStack collectDouble(DoubleFunction doubleFunction) { return this.mutableStack.collectDouble(doubleFunction); } @Override public R collectDouble(DoubleFunction doubleFunction, R target) { return this.mutableStack.collectDouble(doubleFunction, target); } @Override public R flatCollectDouble( Function function, R target) { return this.mutableStack.flatCollectDouble(function, target); } @Override public MutableFloatStack collectFloat(FloatFunction floatFunction) { return this.mutableStack.collectFloat(floatFunction); } @Override public R collectFloat(FloatFunction floatFunction, R target) { return this.mutableStack.collectFloat(floatFunction, target); } @Override public R flatCollectFloat( Function function, R target) { return this.mutableStack.flatCollectFloat(function, target); } @Override public MutableIntStack collectInt(IntFunction intFunction) { return this.mutableStack.collectInt(intFunction); } @Override public R collectInt(IntFunction intFunction, R target) { return this.mutableStack.collectInt(intFunction, target); } @Override public R flatCollectInt( Function function, R target) { return this.mutableStack.flatCollectInt(function, target); } @Override public MutableLongStack collectLong(LongFunction longFunction) { return this.mutableStack.collectLong(longFunction); } @Override public R collectLong(LongFunction longFunction, R target) { return this.mutableStack.collectLong(longFunction, target); } @Override public R flatCollectLong( Function function, R target) { return this.mutableStack.flatCollectLong(function, target); } @Override public MutableShortStack collectShort(ShortFunction shortFunction) { return this.mutableStack.collectShort(shortFunction); } @Override public R collectShort(ShortFunction shortFunction, R target) { return this.mutableStack.collectShort(shortFunction, target); } @Override public R flatCollectShort( Function function, R target) { return this.mutableStack.flatCollectShort(function, target); } @Override public MutableStack collectWith(Function2 function, P parameter) { return this.mutableStack.collectWith(function, parameter); } @Override public MutableStack collectIf(Predicate predicate, Function function) { return this.mutableStack.collectIf(predicate, function); } @Override public MutableStack flatCollect(Function> function) { return this.mutableStack.flatCollect(function); } @Override public MutableStack> zip(Iterable that) { return this.mutableStack.zip(that); } @Override public MutableStack> zipWithIndex() { return this.mutableStack.zipWithIndex(); } @Override public int size() { return this.mutableStack.size(); } @Override public boolean isEmpty() { return this.mutableStack.isEmpty(); } @Override public boolean notEmpty() { return this.mutableStack.notEmpty(); } @Override public T getFirst() { return this.mutableStack.getFirst(); } @Override public T getLast() { return this.mutableStack.getLast(); } @Override public T getOnly() { return this.mutableStack.getOnly(); } @Override public boolean contains(Object object) { return this.mutableStack.contains(object); } @Override public boolean containsAllIterable(Iterable source) { return this.mutableStack.containsAllIterable(source); } @Override public boolean containsAll(Collection source) { return this.mutableStack.containsAll(source); } @Override public boolean containsAllArguments(Object... elements) { return this.mutableStack.containsAllArguments(elements); } @Override public > R select(Predicate predicate, R target) { return this.mutableStack.select(predicate, target); } @Override public > R selectWith(Predicate2 predicate, P parameter, R targetCollection) { return this.mutableStack.selectWith(predicate, parameter, targetCollection); } @Override public > R reject(Predicate predicate, R target) { return this.mutableStack.reject(predicate, target); } @Override public > R rejectWith(Predicate2 predicate, P parameter, R targetCollection) { return this.mutableStack.rejectWith(predicate, parameter, targetCollection); } @Override public > R collect(Function function, R target) { return this.mutableStack.collect(function, target); } @Override public > R collectWith(Function2 function, P parameter, R targetCollection) { return this.mutableStack.collectWith(function, parameter, targetCollection); } @Override public > R collectIf(Predicate predicate, Function function, R target) { return this.mutableStack.collectIf(predicate, function, target); } @Override public > R flatCollect(Function> function, R target) { return this.mutableStack.flatCollect(function, target); } @Override public T detect(Predicate predicate) { return this.mutableStack.detect(predicate); } @Override public

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

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

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

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

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

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

boolean noneSatisfyWith(Predicate2 predicate, P parameter) { return this.mutableStack.noneSatisfyWith(predicate, parameter); } @Override public IV injectInto(IV injectedValue, Function2 function) { return this.mutableStack.injectInto(injectedValue, function); } @Override public int injectInto(int injectedValue, IntObjectToIntFunction intObjectToIntFunction) { return this.mutableStack.injectInto(injectedValue, intObjectToIntFunction); } @Override public long injectInto(long injectedValue, LongObjectToLongFunction longObjectToLongFunction) { return this.mutableStack.injectInto(injectedValue, longObjectToLongFunction); } @Override public float injectInto(float injectedValue, FloatObjectToFloatFunction floatObjectToFloatFunction) { return this.mutableStack.injectInto(injectedValue, floatObjectToFloatFunction); } @Override public double injectInto(double injectedValue, DoubleObjectToDoubleFunction doubleObjectToDoubleFunction) { return this.mutableStack.injectInto(injectedValue, doubleObjectToDoubleFunction); } @Override public > R into(R target) { return this.mutableStack.into(target); } @Override public MutableList toList() { return this.mutableStack.toList(); } @Override public MutableList toSortedList() { return this.mutableStack.toSortedList(); } @Override public MutableList toSortedList(Comparator comparator) { return this.mutableStack.toSortedList(comparator); } @Override public MutableSet toSet() { return this.mutableStack.toSet(); } @Override public MutableSortedSet toSortedSet() { return this.mutableStack.toSortedSet(); } @Override public MutableSortedSet toSortedSet(Comparator comparator) { return this.mutableStack.toSortedSet(comparator); } @Override public ImmutableStack toImmutable() { return this.mutableStack.toImmutable(); } @Override public MutableBag toBag() { return this.mutableStack.toBag(); } @Override public MutableSortedBag toSortedBag() { return this.mutableStack.toSortedBag(); } @Override public MutableSortedBag toSortedBag(Comparator comparator) { return this.mutableStack.toSortedBag(comparator); } @Override public MutableMap toMap(Function keyFunction, Function valueFunction) { return this.mutableStack.toMap(keyFunction, valueFunction); } @Override public > R toMap(Function keyFunction, Function valueFunction, R target) { return this.mutableStack.toMap(keyFunction, valueFunction, target); } @Override public MutableSortedMap toSortedMap(Function keyFunction, Function valueFunction) { return this.mutableStack.toSortedMap(keyFunction, valueFunction); } @Override public MutableSortedMap toSortedMap(Comparator comparator, Function keyFunction, Function valueFunction) { return this.mutableStack.toSortedMap(comparator, keyFunction, valueFunction); } @Override public MutableBiMap toBiMap(Function keyFunction, Function valueFunction) { return this.mutableStack.toBiMap(keyFunction, valueFunction); } @Override public LazyIterable asLazy() { return this.mutableStack.asLazy(); } @Override public Object[] toArray() { return this.mutableStack.toArray(); } @Override public T[] toArray(T[] a) { return this.mutableStack.toArray(a); } @Override public T min(Comparator comparator) { return this.mutableStack.min(comparator); } @Override public T max(Comparator comparator) { return this.mutableStack.max(comparator); } @Override public T min() { return this.mutableStack.min(); } @Override public T max() { return this.mutableStack.max(); } @Override public int detectIndex(Predicate predicate) { return this.mutableStack.detectIndex(predicate); } @Override public > T minBy(Function function) { return this.mutableStack.minBy(function); } @Override public > T maxBy(Function function) { return this.mutableStack.maxBy(function); } @Override public long sumOfInt(IntFunction intFunction) { return this.mutableStack.sumOfInt(intFunction); } @Override public double sumOfFloat(FloatFunction floatFunction) { return this.mutableStack.sumOfFloat(floatFunction); } @Override public long sumOfLong(LongFunction longFunction) { return this.mutableStack.sumOfLong(longFunction); } @Override public double sumOfDouble(DoubleFunction doubleFunction) { return this.mutableStack.sumOfDouble(doubleFunction); } @Override public MutableObjectLongMap sumByInt(Function groupBy, IntFunction function) { MutableObjectLongMap result = ObjectLongMaps.mutable.empty(); return this.injectInto(result, PrimitiveFunctions.sumByIntFunction(groupBy, function)); } @Override public MutableObjectDoubleMap sumByFloat(Function groupBy, FloatFunction function) { MutableObjectDoubleMap result = ObjectDoubleMaps.mutable.empty(); return this.injectInto(result, PrimitiveFunctions.sumByFloatFunction(groupBy, function)); } @Override public MutableObjectLongMap sumByLong(Function groupBy, LongFunction function) { MutableObjectLongMap result = ObjectLongMaps.mutable.empty(); return this.injectInto(result, PrimitiveFunctions.sumByLongFunction(groupBy, function)); } @Override public MutableObjectDoubleMap sumByDouble(Function groupBy, DoubleFunction function) { MutableObjectDoubleMap result = ObjectDoubleMaps.mutable.empty(); return this.injectInto(result, PrimitiveFunctions.sumByDoubleFunction(groupBy, function)); } @Override public String makeString() { return this.mutableStack.makeString(); } @Override public String makeString(String separator) { return this.mutableStack.makeString(separator); } @Override public String makeString(String start, String separator, String end) { return this.mutableStack.makeString(start, separator, end); } @Override public void appendString(Appendable appendable) { this.mutableStack.appendString(appendable); } @Override public void appendString(Appendable appendable, String separator) { this.mutableStack.appendString(appendable, separator); } @Override public void appendString(Appendable appendable, String start, String separator, String end) { this.mutableStack.appendString(appendable, start, separator, end); } @Override public MutableListMultimap groupBy(Function function) { return this.mutableStack.groupBy(function); } @Override public > R groupBy(Function function, R target) { return this.mutableStack.groupBy(function, target); } @Override public MutableListMultimap groupByEach(Function> function) { return this.mutableStack.groupByEach(function); } @Override public > R groupByEach(Function> function, R target) { return this.mutableStack.groupByEach(function, target); } @Override public MutableMap groupByUniqueKey(Function function) { return this.mutableStack.groupByUniqueKey(function); } @Override public > R groupByUniqueKey(Function function, R target) { return this.mutableStack.groupByUniqueKey(function, target); } @Override public >> R zip(Iterable that, R target) { return this.mutableStack.zip(that, target); } @Override public >> R zipWithIndex(R target) { return this.mutableStack.zipWithIndex(target); } @Override public RichIterable> chunk(int size) { return this.mutableStack.chunk(size); } @Override public MutableStack tap(Procedure procedure) { this.forEach(procedure); return this; } @Override public void each(Procedure procedure) { this.mutableStack.forEach(procedure); } @Override public T peek() { return this.mutableStack.peek(); } @Override public ListIterable peek(int count) { return this.mutableStack.peek(count); } @Override public T peekAt(int index) { return this.mutableStack.peekAt(index); } @Override public String toString() { return this.mutableStack.toString(); } @Override public void forEachWithIndex(ObjectIntProcedure objectIntProcedure) { this.mutableStack.forEachWithIndex(objectIntProcedure); } @Override public void forEachWithIndex(int fromIndex, int toIndex, ObjectIntProcedure objectIntProcedure) { this.mutableStack.forEachWithIndex(fromIndex, toIndex, objectIntProcedure); } @Override public MutableStack collectWithIndex(ObjectIntToObjectFunction function) { return this.mutableStack.collectWithIndex(function); } @Override public

void forEachWith(Procedure2 procedure, P parameter) { this.mutableStack.forEachWith(procedure, parameter); } @Override public MutableStack asUnmodifiable() { return this; } @Override public MutableStack asSynchronized() { return this.mutableStack.asSynchronized(); } @Override public boolean equals(Object obj) { return this.mutableStack.equals(obj); } @Override public int hashCode() { return this.mutableStack.hashCode(); } @Override public int indexOf(Object object) { return this.mutableStack.indexOf(object); } @Override public boolean corresponds(OrderedIterable other, Predicate2 predicate) { return this.mutableStack.corresponds(other, predicate); } @Override public void forEach(int startIndex, int endIndex, Procedure procedure) { this.mutableStack.forEach(startIndex, endIndex, procedure); } @Override public MutableStack takeWhile(Predicate predicate) { return this.mutableStack.takeWhile(predicate); } @Override public MutableStack dropWhile(Predicate predicate) { return this.mutableStack.dropWhile(predicate); } @Override public PartitionMutableStack partitionWhile(Predicate predicate) { return this.mutableStack.partitionWhile(predicate); } @Override public MutableStack distinct() { return this.mutableStack.distinct(); } }