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

org.eclipse.collections.impl.lazy.primitive.FlatCollectFloatToObjectIterable 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.lazy.primitive;

import java.util.Iterator;
import java.util.NoSuchElementException;
import java.util.Optional;

import org.eclipse.collections.api.FloatIterable;
import org.eclipse.collections.api.block.function.primitive.FloatToObjectFunction;
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.impl.EmptyIterator;
import org.eclipse.collections.impl.block.factory.Predicates;
import org.eclipse.collections.api.iterator.FloatIterator;
import org.eclipse.collections.impl.block.procedure.AdaptObjectIntProcedureToProcedure;
import org.eclipse.collections.impl.lazy.AbstractLazyIterable;
import org.eclipse.collections.impl.utility.Iterate;

/**
 * This file was automatically generated from template file flatCollectPrimitiveToObjectIterable.stg.
 */
public class FlatCollectFloatToObjectIterable
        extends AbstractLazyIterable
{
    private final FloatIterable iterable;
    private final FloatToObjectFunction> function;

    public FlatCollectFloatToObjectIterable(
            FloatIterable iterable,
            FloatToObjectFunction> function)
    {
        this.iterable = iterable;
        this.function = function;
    }

    @Override
    public void each(Procedure procedure)
    {
        this.iterable.forEach((float each) -> Iterate.forEach(this.function.valueOf(each), procedure));
    }

    @Override
    public void forEachWithIndex(ObjectIntProcedure objectIntProcedure)
    {
        Procedure innerProcedure = new AdaptObjectIntProcedureToProcedure<>(objectIntProcedure);
        this.iterable.forEach(each ->
        {
            Iterable iterable = this.function.valueOf(each);
            Iterate.forEach(iterable, innerProcedure);
        });
    }

    @Override
    public 

void forEachWith(Procedure2 procedure, P parameter) { this.iterable.forEach((float each) -> Iterate.forEachWith(this.function.valueOf(each), procedure, parameter)); } @Override public Iterator iterator() { return new FlatCollectFloatIterator<>(this.iterable, this.function); } @Override public V detect(Predicate predicate) { V[] result = (V[]) new Object[1]; this.iterable.anySatisfy(each -> { Iterable it = this.function.valueOf(each); return Iterate.anySatisfy(it, each1 -> { if (predicate.accept(each1)) { result[0] = each1; return true; } return false; }); }); return result[0]; } @Override public Optional detectOptional(Predicate predicate) { V[] result = (V[]) new Object[1]; this.iterable.anySatisfy(each -> { Iterable it = this.function.valueOf(each); if (iterable == null) { throw new NullPointerException(); } return Iterate.anySatisfy(it, each1 -> { if (predicate.accept(each1)) { if (each1 == null) { throw new NullPointerException(); } result[0] = each1; return true; } return false; }); }); return Optional.ofNullable(result[0]); } @Override public boolean anySatisfy(Predicate predicate) { return this.iterable.anySatisfy(each -> Iterate.anySatisfy(this.function.valueOf(each), predicate)); } @Override public

boolean anySatisfyWith(Predicate2 predicate, P parameter) { return this.anySatisfy(Predicates.bind(predicate, parameter)); } @Override public boolean allSatisfy(Predicate predicate) { return this.iterable.allSatisfy(each -> Iterate.allSatisfy(this.function.valueOf(each), predicate)); } @Override public

boolean allSatisfyWith(Predicate2 predicate, P parameter) { return this.allSatisfy(Predicates.bind(predicate, parameter)); } @Override public boolean noneSatisfy(Predicate predicate) { return this.iterable.noneSatisfy(each -> Iterate.anySatisfy(this.function.valueOf(each), predicate)); } @Override public

boolean noneSatisfyWith(Predicate2 predicate, P parameter) { return this.noneSatisfy(Predicates.bind(predicate, parameter)); } private final class FlatCollectFloatIterator implements Iterator { private final FloatIterator iterator; private final FloatToObjectFunction> function; private Iterator innerIterator = EmptyIterator.getInstance(); public FlatCollectFloatIterator( FloatIterable iterable, FloatToObjectFunction> newFunction) { this(iterable.floatIterator(), newFunction); } public FlatCollectFloatIterator( FloatIterator newIterator, FloatToObjectFunction> newFunction) { this.iterator = newIterator; this.function = newFunction; } @Override public void remove() { throw new UnsupportedOperationException("Cannot remove from a flatCollectFloat iterator"); } @Override public boolean hasNext() { while (true) { if (this.innerIterator.hasNext()) { return true; } if (!this.iterator.hasNext()) { return false; } this.innerIterator = this.function.valueOf(this.iterator.next()).iterator(); } } @Override public V next() { if (!this.hasNext()) { throw new NoSuchElementException(); } return this.innerIterator.next(); } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy