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

org.eclipse.collections.impl.utility.primitive.LazyByteIterate Maven / Gradle / Ivy

/*
 * Copyright (c) 2015 Goldman Sachs.
 * 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.utility.primitive;

import org.eclipse.collections.api.ByteIterable;
import org.eclipse.collections.api.LazyByteIterable;
import org.eclipse.collections.api.LazyIterable;
import org.eclipse.collections.api.block.function.primitive.ByteToObjectFunction;
import org.eclipse.collections.api.block.predicate.primitive.BytePredicate;
import org.eclipse.collections.impl.factory.primitive.ByteLists;
import org.eclipse.collections.impl.lazy.primitive.CollectByteToObjectIterable;
import org.eclipse.collections.impl.lazy.primitive.LazyByteIterableAdapter;
import org.eclipse.collections.impl.lazy.primitive.SelectByteIterable;

/**
 * LazyByteIterate is a factory class which creates "deferred" byte iterables around the specified byte iterables. A "deferred"
 * byte iterable performs some operation, such as filtering or transforming, when the result byte iterable is iterated over.  This
 * makes the operation very memory efficient, because you don't have to create intermediate collections during the
 * operation.
 * This file was automatically generated from template file lazyPrimitiveIterate.stg.
 *
 * @since 5.0
 */
public final class LazyByteIterate
{
    private static final LazyByteIterable EMPTY_ITERABLE = ByteLists.immutable.of().asLazy();

    private LazyByteIterate()
    {
        throw new AssertionError("Suppress default constructor for noninstantiability");
    }

    /**
     * Creates a deferred byte iterable for the specified byte iterable.
     */
    public static LazyByteIterable adapt(ByteIterable iterable)
    {
        return new LazyByteIterableAdapter(iterable);
    }

    /**
     * Creates a deferred filtering byte iterable for the specified byte iterable.
     */
    public static LazyByteIterable select(ByteIterable iterable, BytePredicate predicate)
    {
        return new SelectByteIterable(iterable, predicate);
    }

    /**
     * Creates a deferred transforming byte iterable for the specified byte iterable.
     */
    public static  LazyIterable collect(
            ByteIterable iterable,
            ByteToObjectFunction function)
    {
        return new CollectByteToObjectIterable(iterable, function);
    }

    /**
     * Creates a deferred filtering and transforming byte iterable for the specified byte iterable.
     */
    public static  LazyIterable collectIf(
            ByteIterable iterable,
            BytePredicate predicate,
            ByteToObjectFunction function)
    {
        return LazyByteIterate.select(iterable, predicate).collect(function);
    }

    public static LazyByteIterable empty()
    {
        return EMPTY_ITERABLE;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy