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

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

There is a newer version: 12.0.0.M3
Show newest version
/*
 * Copyright (c) 2017 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.BooleanIterable;
import org.eclipse.collections.api.LazyBooleanIterable;
import org.eclipse.collections.api.LazyIterable;
import org.eclipse.collections.api.block.function.primitive.BooleanToObjectFunction;
import org.eclipse.collections.api.block.predicate.primitive.BooleanPredicate;
import org.eclipse.collections.impl.factory.primitive.BooleanLists;
import org.eclipse.collections.impl.lazy.primitive.CollectBooleanToObjectIterable;
import org.eclipse.collections.impl.lazy.primitive.LazyBooleanIterableAdapter;
import org.eclipse.collections.impl.lazy.primitive.SelectBooleanIterable;

/**
 * LazyBooleanIterate is a factory class which creates "deferred" boolean iterables around the specified boolean iterables. A "deferred"
 * boolean iterable performs some operation, such as filtering or transforming, when the result boolean 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 LazyBooleanIterate
{
    private static final LazyBooleanIterable EMPTY_ITERABLE = BooleanLists.immutable.of().asLazy();

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

    /**
     * Creates a deferred boolean iterable for the specified boolean iterable.
     */
    public static LazyBooleanIterable adapt(BooleanIterable iterable)
    {
        return new LazyBooleanIterableAdapter(iterable);
    }

    /**
     * Creates a deferred filtering boolean iterable for the specified boolean iterable.
     */
    public static LazyBooleanIterable select(BooleanIterable iterable, BooleanPredicate predicate)
    {
        return new SelectBooleanIterable(iterable, predicate);
    }

    /**
     * Creates a deferred transforming boolean iterable for the specified boolean iterable.
     */
    public static  LazyIterable collect(
            BooleanIterable iterable,
            BooleanToObjectFunction function)
    {
        return new CollectBooleanToObjectIterable(iterable, function);
    }

    /**
     * Creates a deferred filtering and transforming boolean iterable for the specified boolean iterable.
     */
    public static  LazyIterable collectIf(
            BooleanIterable iterable,
            BooleanPredicate predicate,
            BooleanToObjectFunction function)
    {
        return LazyBooleanIterate.select(iterable, predicate).collect(function);
    }

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy