Package com.gs.collections.impl.list.immutable.primitive

Source Code of com.gs.collections.impl.list.immutable.primitive.ImmutableLongEmptyList

/*
* 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.list.immutable.primitive;

import java.io.IOException;
import java.io.Serializable;
import java.util.NoSuchElementException;

import com.gs.collections.api.LongIterable;
import com.gs.collections.api.LazyLongIterable;
import com.gs.collections.api.bag.primitive.MutableLongBag;
import com.gs.collections.api.block.function.primitive.LongToObjectFunction;
import com.gs.collections.api.block.function.primitive.ObjectLongToObjectFunction;
import com.gs.collections.api.block.function.primitive.ObjectLongIntToObjectFunction;
import com.gs.collections.api.block.predicate.primitive.LongPredicate;
import com.gs.collections.api.block.procedure.primitive.LongProcedure;
import com.gs.collections.api.block.procedure.primitive.LongIntProcedure;
import com.gs.collections.api.iterator.LongIterator;
import com.gs.collections.api.list.ImmutableList;
import com.gs.collections.api.list.primitive.ImmutableLongList;
import com.gs.collections.api.list.primitive.LongList;
import com.gs.collections.api.list.primitive.MutableLongList;
import com.gs.collections.api.set.primitive.MutableLongSet;
import com.gs.collections.impl.bag.mutable.primitive.LongHashBag;
import com.gs.collections.impl.factory.Lists;
import com.gs.collections.impl.factory.primitive.LongLists;
import com.gs.collections.impl.lazy.primitive.LazyLongIterableAdapter;
import com.gs.collections.impl.lazy.primitive.ReverseLongIterable;
import com.gs.collections.impl.list.mutable.primitive.LongArrayList;
import com.gs.collections.impl.set.mutable.primitive.LongHashSet;
import net.jcip.annotations.Immutable;

/**
* ImmutableLongEmptyList is an optimization for {@link ImmutableLongList} of size 0.
* This file was automatically generated from template file immutablePrimitiveEmptyList.stg.
*/
@Immutable
final class ImmutableLongEmptyList implements ImmutableLongList, Serializable
{
    static final ImmutableLongList INSTANCE = new ImmutableLongEmptyList();
    private static final long serialVersionUID = 1L;

    private Object readResolve()
    {
        return INSTANCE;
    }

    public long get(int index)
    {
        throw new IndexOutOfBoundsException("Index: " + index + ", Size: 0");
    }

    public long getFirst()
    {
        throw new IndexOutOfBoundsException("Index: 0, Size: 0");
    }

    public long getLast()
    {
        throw new IndexOutOfBoundsException("Index: 0, Size: 0");
    }

    public int indexOf(long value)
    {
        return -1;
    }

    public int lastIndexOf(long value)
    {
        return -1;
    }

    public LongIterator longIterator()
    {
        return new InternalLongIterator();
    }

    public void forEach(LongProcedure procedure)
    {
    }

    public void forEachWithIndex(LongIntProcedure procedure)
    {
    }

    public int count(LongPredicate predicate)
    {
        return 0;
    }

    public boolean anySatisfy(LongPredicate predicate)
    {
        return false;
    }

    public boolean allSatisfy(LongPredicate predicate)
    {
        return true;
    }

    public boolean noneSatisfy(LongPredicate predicate)
    {
        return true;
    }

    public ImmutableLongList select(LongPredicate predicate)
    {
        return this;
    }

    public ImmutableLongList reject(LongPredicate predicate)
    {
        return this;
    }

    public long detectIfNone(LongPredicate predicate, long ifNone)
    {
        return ifNone;
    }

    public <V> ImmutableList<V> collect(LongToObjectFunction<? extends V> function)
    {
        return Lists.immutable.of();
    }

    public long sum()
    {
        return 0;
    }

    public long max()
    {
        throw new NoSuchElementException();
    }

    public long maxIfEmpty(long defaultValue)
    {
        return defaultValue;
    }

    public long min()
    {
        throw new NoSuchElementException();
    }

    public long minIfEmpty(long defaultValue)
    {
        return defaultValue;
    }

    public double average()
    {
        throw new ArithmeticException();
    }

    public double median()
    {
        throw new ArithmeticException();
    }

    public long[] toSortedArray()
    {
        return new long[0];
    }

    public MutableLongList toSortedList()
    {
        return new LongArrayList();
    }

    public long dotProduct(LongList list)
    {
        if (!list.isEmpty())
        {
            throw new IllegalArgumentException("Lists used in dotProduct must be the same size");
        }
        return 0;
    }

    public long[] toArray()
    {
        return new long[0];
    }

    public boolean contains(long value)
    {
        return false;
    }

    public boolean containsAll(long... source)
    {
        return source.length == 0;
    }

    public boolean containsAll(LongIterable source)
    {
        return source.isEmpty();
    }

    public LazyLongIterable asReversed()
    {
        return ReverseLongIterable.adapt(this);
    }

    public MutableLongList toList()
    {
        return new LongArrayList();
    }

    public MutableLongSet toSet()
    {
        return new LongHashSet();
    }

    public MutableLongBag toBag()
    {
        return new LongHashBag();
    }

    public LazyLongIterable asLazy()
    {
        return new LazyLongIterableAdapter(this);
    }

    public ImmutableLongList toImmutable()
    {
        return this;
    }

    public ImmutableLongEmptyList toReversed()
    {
        return this;
    }

    public ImmutableLongList newWith(long element)
    {
        return LongLists.immutable.with(element);
    }

    public ImmutableLongList newWithout(long element)
    {
        return this;
    }

    public ImmutableLongList newWithAll(LongIterable elements)
    {
        return LongLists.immutable.withAll(elements);
    }

    public ImmutableLongList newWithoutAll(LongIterable elements)
    {
        return this;
    }

    public int size()
    {
        return 0;
    }

    public boolean isEmpty()
    {
        return true;
    }

    public boolean notEmpty()
    {
        return false;
    }

    public <T> T injectInto(T injectedValue, ObjectLongToObjectFunction<? super T, ? extends T> function)
    {
        return injectedValue;
    }

    public <T> T injectIntoWithIndex(T injectedValue, ObjectLongIntToObjectFunction<? super T, ? extends T> function)
    {
        return injectedValue;
    }

    @Override
    public boolean equals(Object otherList)
    {
        if (otherList == this)
        {
            return true;
        }
        if (!(otherList instanceof LongList))
        {
            return false;
        }
        LongList list = (LongList) otherList;
        return list.isEmpty();
    }

    @Override
    public int hashCode()
    {
        return 1;
    }

    @Override
    public String toString()
    {
        return "[]";
    }

    public String makeString()
    {
        return "";
    }

    public String makeString(String separator)
    {
        return "";
    }

    public String makeString(String start, String separator, String end)
    {
        return start + end;
    }

    public void appendString(Appendable appendable)
    {
    }

    public void appendString(Appendable appendable, String separator)
    {
    }

    public void appendString(Appendable appendable, String start, String separator, String end)
    {
        try
        {
            appendable.append(start);
            appendable.append(end);
        }
        catch (IOException e)
        {
            throw new RuntimeException(e);
        }
    }

    public ImmutableLongList subList(int fromIndex, int toIndex)
    {
        throw new UnsupportedOperationException("subList not yet implemented!");
    }

    private static class InternalLongIterator implements LongIterator
    {
        public boolean hasNext()
        {
            return false;
        }

        public long next()
        {
            throw new NoSuchElementException();
        }
    }
}
TOP

Related Classes of com.gs.collections.impl.list.immutable.primitive.ImmutableLongEmptyList

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.