@Immutable public class SelectInstancesOfIterable<T> extends AbstractLazyIterable<T>
Constructor and Description |
---|
SelectInstancesOfIterable(Iterable<?> newAdapted,
Class<T> clazz) |
Modifier and Type | Method and Description |
---|---|
boolean |
allSatisfy(Predicate<? super T> predicate)
Returns true if the predicate evaluates to true for every element of the iterable or if the iterable is empty.
|
boolean |
anySatisfy(Predicate<? super T> predicate)
Returns true if the predicate evaluates to true for any element of the iterable.
|
T |
detect(Predicate<? super T> predicate)
Returns the first element of the iterable for which the predicate evaluates to true or null in the case where no
element returns true.
|
Optional<T> |
detectOptional(Predicate<? super T> predicate)
Returns the first element of the iterable for which the predicate evaluates to true as an Optional.
|
void |
each(Procedure<? super T> procedure)
The procedure is executed for each element in the iterable.
|
<P> void |
forEachWith(Procedure2<? super T,? super P> procedure,
P parameter)
The procedure2 is evaluated for each element in the iterable with the specified parameter provided
as the second argument.
|
void |
forEachWithIndex(ObjectIntProcedure<? super T> objectIntProcedure)
Iterates over the iterable passing each element and the current relative int index to the specified instance of
ObjectIntProcedure.
|
T |
getFirst()
Returns the first element of an iterable.
|
Iterator<T> |
iterator() |
boolean |
noneSatisfy(Predicate<? super T> predicate)
Returns true if the predicate evaluates to false for every element of the iterable or if the iterable is empty.
|
aggregateBy, aggregateInPlaceBy, asLazy, chunk, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, concatenate, distinct, drop, dropWhile, flatCollect, getLast, getOnly, groupBy, groupByEach, groupByUniqueKey, into, isEmpty, partition, partitionWith, reject, rejectWith, select, selectInstancesOf, selectWith, size, sumByDouble, sumByFloat, sumByInt, sumByLong, take, takeWhile, tap, toArray, toStack, zip, zipWithIndex
allSatisfyWith, anySatisfyWith, appendString, appendString, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, contains, containsAll, containsAllArguments, containsAllIterable, count, countWith, detectIfNone, detectWith, detectWithIfNone, detectWithOptional, flatCollect, forEach, groupBy, groupByEach, groupByUniqueKey, injectInto, injectInto, injectInto, injectInto, injectInto, max, max, maxBy, min, min, minBy, noneSatisfyWith, reject, rejectWith, select, selectWith, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, toArray, toBag, toList, toMap, toSet, toSortedBag, toSortedBag, toSortedBagBy, toSortedList, toSortedListBy, toSortedMap, toSortedMap, toSortedSet, toSortedSet, toSortedSetBy, toString, zip, zipWithIndex
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
allSatisfyWith, anySatisfyWith, appendString, appendString, appendString, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, contains, containsAll, containsAllArguments, containsAllIterable, count, countWith, detectIfNone, detectWith, detectWithIfNone, detectWithOptional, flatCollect, groupBy, groupByEach, groupByUniqueKey, injectInto, injectInto, injectInto, injectInto, injectInto, makeString, makeString, makeString, max, max, maxBy, min, min, minBy, noneSatisfyWith, notEmpty, reduce, reduceInPlace, reduceInPlace, reject, rejectWith, select, selectWith, summarizeDouble, summarizeFloat, summarizeInt, summarizeLong, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, toArray, toBag, toList, toMap, toSet, toSortedBag, toSortedBag, toSortedBagBy, toSortedList, toSortedList, toSortedListBy, toSortedMap, toSortedMap, toSortedSet, toSortedSet, toSortedSetBy, toString, zip, zipWithIndex
forEach
forEach, spliterator
public void each(Procedure<? super T> procedure)
RichIterable
Example using a Java 8 lambda expression:
people.each(person -> LOGGER.info(person.getName()));
Example using an anonymous inner class:
people.each(new ProcedureThis method is a variant of() { public void value(Person person) { LOGGER.info(person.getName()); } });
InternalIterable.forEach(Procedure)
that has a signature conflict with Iterable.forEach(java.util.function.Consumer)
.public void forEachWithIndex(ObjectIntProcedure<? super T> objectIntProcedure)
InternalIterable
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() { public void value(Person person, int index) { LOGGER.info("Index: " + index + " person: " + person.getName()); } });
forEachWithIndex
in interface InternalIterable<T>
forEachWithIndex
in class AbstractRichIterable<T>
public <P> void forEachWith(Procedure2<? super T,? super P> procedure, P parameter)
InternalIterable
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() { public void value(Person person, Person other) { if (person.isRelatedTo(other)) { LOGGER.info(person.getName()); } } }, fred);
forEachWith
in interface InternalIterable<T>
forEachWith
in class AbstractRichIterable<T>
public T getFirst()
RichIterable
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.
getFirst
in interface LazyIterable<T>
getFirst
in interface RichIterable<T>
getFirst
in class AbstractLazyIterable<T>
public boolean anySatisfy(Predicate<? super T> predicate)
RichIterable
anySatisfy
in interface RichIterable<T>
anySatisfy
in class AbstractRichIterable<T>
public boolean allSatisfy(Predicate<? super T> predicate)
RichIterable
allSatisfy
in interface RichIterable<T>
allSatisfy
in class AbstractRichIterable<T>
public boolean noneSatisfy(Predicate<? super T> predicate)
RichIterable
noneSatisfy
in interface RichIterable<T>
noneSatisfy
in class AbstractRichIterable<T>
public T detect(Predicate<? super T> predicate)
RichIterable
Example using a Java 8 lambda expression:
Person person = people.detect(person -> person.getFirstName().equals("John") && person.getLastName().equals("Smith"));
Example using an anonymous inner class:
Person person = people.detect(new Predicate<Person>() { public boolean accept(Person person) { return person.getFirstName().equals("John") && person.getLastName().equals("Smith"); } });
detect
in interface RichIterable<T>
detect
in class AbstractRichIterable<T>
public Optional<T> detectOptional(Predicate<? super T> predicate)
RichIterable
Example using a Java 8 lambda expression:
Person person = people.detectOptional(person -> person.getFirstName().equals("John") && person.getLastName().equals("Smith"));
detectOptional
in interface RichIterable<T>
detectOptional
in class AbstractRichIterable<T>
Copyright © 2004–2016. All rights reserved.