Top Description Fields Constructors Methods
org.eclipse.collections.impl.lazy

public Class SelectInstancesOfIterable<T>

extends AbstractLazyIterable<T>
Class Inheritance
Imports
java.util.Iterator, .Optional, org.eclipse.collections.api.block.predicate.Predicate, org.eclipse.collections.api.block.procedure.Procedure, .Procedure2, org.eclipse.collections.api.block.procedure.primitive.ObjectIntProcedure, org.eclipse.collections.impl.block.factory.Predicates, org.eclipse.collections.impl.block.procedure.IfObjectIntProcedure, .IfProcedure, .IfProcedureWith, org.eclipse.collections.impl.lazy.iterator.SelectInstancesOfIterator, org.eclipse.collections.impl.utility.Iterate

A SelectIterable is an iterable that filters a source iterable for instances of a Class as it iterates.

Field Summary

Modifier and TypeField and Description
private final Iterable<?>
private final Class<T>

Constructor Summary

AccessConstructor and Description
public
SelectInstancesOfIterable(Iterable<?> newAdapted, Class<T> clazz)

Method Summary

Modifier and TypeMethod and Description
public boolean
allSatisfy(Predicate<? super T> predicate)

Overrides org.eclipse.collections.impl.AbstractRichIterable.allSatisfy.

Implements org.eclipse.collections.api.RichIterable.allSatisfy.

Returns true if the predicate evaluates to true for every element of the iterable or if the iterable is empty.

public boolean
anySatisfy(Predicate<? super T> predicate)

Overrides org.eclipse.collections.impl.AbstractRichIterable.anySatisfy.

Implements org.eclipse.collections.api.RichIterable.anySatisfy.

Returns true if the predicate evaluates to true for any element of the iterable.

public T
detect(Predicate<? super T> predicate)

Overrides org.eclipse.collections.impl.AbstractRichIterable.detect.

Implements org.eclipse.collections.api.RichIterable.detect.

Returns the first element of the iterable for which the predicate evaluates to true or null in the case where no element returns true.

public Optional<T>
detectOptional(Predicate<? super T> predicate)

Overrides org.eclipse.collections.impl.AbstractRichIterable.detectOptional.

Implements org.eclipse.collections.api.RichIterable.detectOptional.

Returns the first element of the iterable for which the predicate evaluates to true as an Optional.

public void
each(Procedure<? super T> procedure)

Implements org.eclipse.collections.api.RichIterable.each.

The procedure is executed for each element in the iterable.

public <P> void
forEachWith(Procedure2<? super T, ? super P> procedure, P parameter)

Overrides org.eclipse.collections.impl.AbstractRichIterable.forEachWith.

Implements org.eclipse.collections.api.InternalIterable.forEachWith.

The procedure2 is evaluated for each element in the iterable with the specified parameter provided as the second argument.

public void
forEachWithIndex(ObjectIntProcedure<? super T> objectIntProcedure)

Overrides org.eclipse.collections.impl.AbstractRichIterable.forEachWithIndex.

Implements org.eclipse.collections.api.InternalIterable.forEachWithIndex.

Iterates over the iterable passing each element and the current relative int index to the specified instance of ObjectIntProcedure.

public T
public Iterator<T>
iterator()

Implements java.lang.Iterable.iterator.

Returns an iterator over elements of type T.

public boolean
noneSatisfy(Predicate<? super T> predicate)

Overrides org.eclipse.collections.impl.AbstractRichIterable.noneSatisfy.

Implements org.eclipse.collections.api.RichIterable.noneSatisfy.

Returns true if the predicate evaluates to false for every element of the iterable or if the iterable is empty.

Inherited from org.eclipse.collections.impl.lazy.AbstractLazyIterable:
asLazychunkcollectcollectBooleancollectBytecollectCharcollectDoublecollectFloatcollectIfcollectIntcollectLongcollectShortcollectWithconcatenatedistinctdropdropWhileflatCollectgetLastgetOnlygroupBygroupByEachgroupByUniqueKeyintoisEmptymaxByOptionalmaxOptionalmaxOptionalminByOptionalminOptionalminOptionalpartitionpartitionWithrejectrejectWithselectselectInstancesOfselectWithsizesumByDoublesumByFloatsumByIntsumByLongtaketakeWhiletaptoStackzipzipWithIndex

Field Detail

adaptedback to summary
private final Iterable<?> adapted
clazzback to summary
private final Class<T> clazz

Constructor Detail

SelectInstancesOfIterableback to summary
public SelectInstancesOfIterable(Iterable<?> newAdapted, Class<T> clazz)

Method Detail

allSatisfyback to summary
public boolean allSatisfy(Predicate<? super T> predicate)

Overrides org.eclipse.collections.impl.AbstractRichIterable.allSatisfy.

Implements org.eclipse.collections.api.RichIterable.allSatisfy.

Doc from org.eclipse.collections.api.RichIterable.allSatisfy.

Returns true if the predicate evaluates to true for every element of the iterable or if the iterable is empty. Otherwise, returns false.

Annotations
@Override
anySatisfyback to summary
public boolean anySatisfy(Predicate<? super T> predicate)

Overrides org.eclipse.collections.impl.AbstractRichIterable.anySatisfy.

Implements org.eclipse.collections.api.RichIterable.anySatisfy.

Doc from org.eclipse.collections.api.RichIterable.anySatisfy.

Returns true if the predicate evaluates to true for any element of the iterable. Returns false if the iterable is empty, or if no element returned true when evaluating the predicate.

Annotations
@Override
detectback to summary
public T detect(Predicate<? super T> predicate)

Overrides org.eclipse.collections.impl.AbstractRichIterable.detect.

Implements org.eclipse.collections.api.RichIterable.detect.

Doc from org.eclipse.collections.api.RichIterable.detect.

Returns the first element of the iterable for which the predicate evaluates to true or null in the case where no element returns true. This method is commonly called find.

Example using a Java 8 lambda expression:

Person person =
    people.detect(person -> person.getFirstName().equals("John") && person.getLastName().equals("Smith"));
Annotations
@Override
detectOptionalback to summary
public Optional<T> detectOptional(Predicate<? super T> predicate)

Overrides org.eclipse.collections.impl.AbstractRichIterable.detectOptional.

Implements org.eclipse.collections.api.RichIterable.detectOptional.

Doc from org.eclipse.collections.api.RichIterable.detectOptional.

Returns the first element of the iterable for which the predicate evaluates to true as an Optional. This method is commonly called find.

Example using a Java 8 lambda expression:

Person person =
    people.detectOptional(person -> person.getFirstName().equals("John") && person.getLastName().equals("Smith"));

Annotations
@Override
eachback to summary
public void each(Procedure<? super T> procedure)

Implements org.eclipse.collections.api.RichIterable.each.

Doc from org.eclipse.collections.api.RichIterable.each.

The procedure is executed for each element in the iterable.

Example using a Java 8 lambda expression:

people.each(person -> LOGGER.info(person.getName()));
This method is a variant of InternalIterable#forEach(Procedure) that has a signature conflict with Iterable#forEach(java.util.function.Consumer).
Annotations
@Override
forEachWithback to summary
public <P> void forEachWith(Procedure2<? super T, ? super P> procedure, P parameter)

Overrides org.eclipse.collections.impl.AbstractRichIterable.forEachWith.

Implements org.eclipse.collections.api.InternalIterable.forEachWith.

Doc from org.eclipse.collections.api.InternalIterable.forEachWith.

The procedure2 is evaluated for each element in the iterable with the specified parameter provided as the second argument.

Example using a Java 8 lambda:

people.forEachWith((Person person, Person other) ->
    {
        if (person.isRelatedTo(other))
        {
             LOGGER.info(person.getName());
        }
    }, fred);

Example using an anonymous inner class:

people.forEachWith(new Procedure2<Person, Person>()
{
    public void value(Person person, Person other)
    {
        if (person.isRelatedTo(other))
        {
             LOGGER.info(person.getName());
        }
    }
}, fred);
Annotations
@Override
forEachWithIndexback to summary
public void forEachWithIndex(ObjectIntProcedure<? super T> objectIntProcedure)

Overrides org.eclipse.collections.impl.AbstractRichIterable.forEachWithIndex.

Implements org.eclipse.collections.api.InternalIterable.forEachWithIndex.

Doc from org.eclipse.collections.api.InternalIterable.forEachWithIndex.

Iterates over the iterable passing each element and the current relative int index to the specified instance of ObjectIntProcedure.

Example using a Java 8 lambda:

people.forEachWithIndex((Person person, int index) -> LOGGER.info("Index: " + index + " person: " + person.getName()));

Example using an anonymous inner class:

people.forEachWithIndex(new ObjectIntProcedure<Person>()
{
    public void value(Person person, int index)
    {
        LOGGER.info("Index: " + index + " person: " + person.getName());
    }
});
Annotations
@Override
getFirstback to summary
public T getFirst()

Overrides org.eclipse.collections.impl.lazy.AbstractLazyIterable.getFirst.

Implements org.eclipse.collections.api.LazyIterable.getFirst, org.eclipse.collections.api.RichIterable.getFirst.

Doc from org.eclipse.collections.api.RichIterable.getFirst.

Returns the first element of an iterable. In the case of a List it is the element at the first index. In the case of any other Collection, it is the first element that would be returned during an iteration. If the iterable is empty, null is returned. If null is a valid element of the container, then a developer would need to check to see if the iterable is empty to validate that a null result was not due to the container being empty.

The order of Sets are not guaranteed (except for TreeSets and other Ordered Set implementations), so if you use this method, the first element could be any element from the Set.

Annotations
@Override
iteratorback to summary
public Iterator<T> iterator()

Implements java.lang.Iterable.iterator.

Doc from java.lang.Iterable.iterator.

Returns an iterator over elements of type T.

Annotations
@Override
noneSatisfyback to summary
public boolean noneSatisfy(Predicate<? super T> predicate)

Overrides org.eclipse.collections.impl.AbstractRichIterable.noneSatisfy.

Implements org.eclipse.collections.api.RichIterable.noneSatisfy.

Doc from org.eclipse.collections.api.RichIterable.noneSatisfy.

Returns true if the predicate evaluates to false for every element of the iterable or if the iterable is empty. Otherwise, returns false.

Annotations
@Override