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

org.eclipse.collections.impl.lazy.LazyIterableAdapter 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) 2021 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.lazy;

import java.util.Collection;
import java.util.Iterator;
import java.util.Optional;

import org.eclipse.collections.api.LazyIterable;
import org.eclipse.collections.api.block.function.Function;
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.UnmodifiableIteratorAdapter;
import org.eclipse.collections.impl.utility.Iterate;
import org.eclipse.collections.impl.utility.LazyIterate;

/**
 * A LazyIterableAdapter wraps any iterable with the LazyIterable interface.
 */
public class LazyIterableAdapter
        extends AbstractLazyIterable
{
    private final Iterable adapted;

    public LazyIterableAdapter(Iterable newAdapted)
    {
        this.adapted = newAdapted;
    }

    @Override
    public void each(Procedure procedure)
    {
        Iterate.forEach(this.adapted, procedure);
    }

    @Override
    public void forEachWithIndex(ObjectIntProcedure objectIntProcedure)
    {
        Iterate.forEachWithIndex(this.adapted, objectIntProcedure);
    }

    @Override
    public 

void forEachWith(Procedure2 procedure, P parameter) { Iterate.forEachWith(this.adapted, procedure, parameter); } @Override public Iterator iterator() { return new UnmodifiableIteratorAdapter<>(this.adapted.iterator()); } @Override public > R into(R target) { Iterate.addAllIterable(this.adapted, target); return target; } @Override public LazyIterable select(Predicate predicate) { return LazyIterate.select(this.adapted, predicate); } @Override public LazyIterable reject(Predicate predicate) { return LazyIterate.reject(this.adapted, predicate); } @Override public LazyIterable collect(Function function) { return LazyIterate.collect(this.adapted, function); } @Override public LazyIterable flatCollect(Function> function) { return LazyIterate.flatCollect(this.adapted, function); } @Override public LazyIterable collectIf(Predicate predicate, Function function) { return LazyIterate.collectIf(this.adapted, predicate, function); } @Override public LazyIterable take(int count) { return LazyIterate.take(this.adapted, count); } @Override public LazyIterable drop(int count) { return LazyIterate.drop(this.adapted, count); } @Override public LazyIterable takeWhile(Predicate predicate) { return LazyIterate.takeWhile(this.adapted, predicate); } @Override public LazyIterable dropWhile(Predicate predicate) { return LazyIterate.dropWhile(this.adapted, predicate); } @Override public LazyIterable distinct() { return LazyIterate.distinct(this.adapted); } @Override public Object[] toArray() { return Iterate.toArray(this.adapted); } @Override public int size() { return Iterate.sizeOf(this.adapted); } @Override public boolean isEmpty() { return Iterate.isEmpty(this.adapted); } @Override public boolean anySatisfy(Predicate predicate) { return Iterate.anySatisfy(this.adapted, predicate); } @Override public boolean allSatisfy(Predicate predicate) { return Iterate.allSatisfy(this.adapted, predicate); } @Override public boolean noneSatisfy(Predicate predicate) { return Iterate.noneSatisfy(this.adapted, predicate); } @Override public

boolean anySatisfyWith(Predicate2 predicate, P parameter) { return Iterate.anySatisfyWith(this.adapted, predicate, parameter); } @Override public

boolean allSatisfyWith(Predicate2 predicate, P parameter) { return Iterate.allSatisfyWith(this.adapted, predicate, parameter); } @Override public

boolean noneSatisfyWith(Predicate2 predicate, P parameter) { return Iterate.noneSatisfyWith(this.adapted, predicate, parameter); } @Override public T getFirst() { return Iterate.getFirst(this.adapted); } @Override public T getLast() { return Iterate.getLast(this.adapted); } @Override public T detect(Predicate predicate) { return Iterate.detect(this.adapted, predicate); } @Override public

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

Optional detectWithOptional(Predicate2 predicate, P parameter) { return Iterate.detectWithOptional(this.adapted, predicate, parameter); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy