java.lang.Iterable<T>
, InternalIterable<T>
, LazyIterable<T>
, RichIterable<T>
public class LazyIterableAdapter<T> extends AbstractLazyIterable<T>
Constructor | Description |
---|---|
LazyIterableAdapter(java.lang.Iterable<T> newAdapted) |
Modifier and Type | Method | 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.
|
<P> boolean |
allSatisfyWith(Predicate2<? super T,? super P> predicate,
P parameter) |
Returns true if the predicate evaluates to true for every element of the collection, or returns false.
|
boolean |
anySatisfy(Predicate<? super T> predicate) |
Returns true if the predicate evaluates to true for any element of the iterable.
|
<P> boolean |
anySatisfyWith(Predicate2<? super T,? super P> predicate,
P parameter) |
Returns true if the predicate evaluates to true for any element of the collection, or return false.
|
<V> LazyIterable<V> |
collect(Function<? super T,? extends V> function) |
Creates a deferred iterable for collecting elements from the current iterable.
|
<V> LazyIterable<V> |
collectIf(Predicate<? super T> predicate,
Function<? super T,? extends V> function) |
Creates a deferred iterable for selecting and collecting elements from the current 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.
|
java.util.Optional<T> |
detectOptional(Predicate<? super T> predicate) |
Returns the first element of the iterable for which the predicate evaluates to true as an Optional.
|
<P> T |
detectWith(Predicate2<? super T,? super P> predicate,
P parameter) |
Returns the first element that evaluates to true for the specified predicate2 and parameter, or null if none
evaluate to true.
|
<P> java.util.Optional<T> |
detectWithOptional(Predicate2<? super T,? super P> predicate,
P parameter) |
Returns the first element that evaluates to true for the specified predicate2 and parameter as an Optional.
|
LazyIterable<T> |
distinct() |
Creates a deferred distinct iterable to get distinct elements from the current iterable.
|
LazyIterable<T> |
drop(int count) |
Creates a deferred drop iterable for the current iterable using the specified count as the limit.
|
LazyIterable<T> |
dropWhile(Predicate<? super T> predicate) |
|
void |
each(Procedure<? super T> procedure) |
The procedure is executed for each element in the iterable.
|
<V> LazyIterable<V> |
flatCollect(Function<? super T,? extends java.lang.Iterable<V>> function) |
Creates a deferred flattening iterable for the current 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.
|
T |
getLast() |
Returns the last element of an iterable.
|
<R extends java.util.Collection<T>> |
into(R target) |
Adds all the elements in this iterable to the specific target Collection.
|
boolean |
isEmpty() |
Returns true if this iterable has zero items.
|
java.util.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.
|
<P> boolean |
noneSatisfyWith(Predicate2<? super T,? super P> predicate,
P parameter) |
Returns true if the predicate evaluates to false for every element of the collection, or return false.
|
LazyIterable<T> |
reject(Predicate<? super T> predicate) |
Creates a deferred iterable for rejecting elements from the current iterable.
|
LazyIterable<T> |
select(Predicate<? super T> predicate) |
Creates a deferred iterable for selecting elements from the current iterable.
|
int |
size() |
Returns the number of items in this iterable.
|
LazyIterable<T> |
take(int count) |
Creates a deferred take iterable for the current iterable using the specified count as the limit.
|
LazyIterable<T> |
takeWhile(Predicate<? super T> predicate) |
|
java.lang.Object[] |
toArray() |
Converts this iterable to an array.
|
aggregateBy, aggregateInPlaceBy, asLazy, chunk, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectInt, collectLong, collectShort, collectWith, concatenate, getOnly, groupBy, groupByEach, groupByUniqueKey, maxByOptional, maxOptional, maxOptional, minByOptional, minOptional, minOptional, partition, partitionWith, rejectWith, selectInstancesOf, selectWith, sumByDouble, sumByFloat, sumByInt, sumByLong, tap, toArray, toStack, zip, zipWithIndex
appendString, appendString, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, contains, containsAll, containsAllArguments, containsAllIterable, count, countBy, countByWith, countWith, detectWithIfNone, flatCollect, forEach, groupBy, groupByEach, groupByUniqueKey, injectInto, injectInto, injectInto, injectInto, injectInto, max, max, maxBy, min, min, minBy, reject, rejectWith, select, selectWith, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, toBag, toList, toMap, toSet, toSortedBag, toSortedBag, toSortedBagBy, toSortedListBy, toSortedMap, toSortedMap, toSortedMapBy, toSortedSet, toSortedSet, toSortedSetBy, toString, zip, zipWithIndex
forEach, forEach
flatCollectWith
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
appendString, appendString, appendString, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, contains, containsAll, containsAllArguments, containsAllIterable, count, countBy, countBy, countByWith, countByWith, countWith, detectIfNone, detectWithIfNone, flatCollect, flatCollectWith, groupBy, groupByEach, groupByUniqueKey, injectInto, injectInto, injectInto, injectInto, injectInto, makeString, makeString, makeString, max, max, maxBy, min, min, minBy, notEmpty, reduce, reduceInPlace, reduceInPlace, reject, rejectWith, select, selectWith, summarizeDouble, summarizeFloat, summarizeInt, summarizeLong, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, toBag, toList, toMap, toSet, toSortedBag, toSortedBag, toSortedBagBy, toSortedList, toSortedList, toSortedListBy, toSortedMap, toSortedMap, toSortedMapBy, toSortedSet, toSortedSet, toSortedSetBy, toString, zip, zipWithIndex
public LazyIterableAdapter(java.lang.Iterable<T> newAdapted)
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 Procedure<Person>() { public void value(Person 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)
.InternalIterable.forEach(Procedure)
,
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<Person>() { 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<Person, Person>() { 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 java.util.Iterator<T> iterator()
public <R extends java.util.Collection<T>> R into(R target)
RichIterable
into
in interface LazyIterable<T>
into
in interface RichIterable<T>
into
in class AbstractLazyIterable<T>
public LazyIterable<T> select(Predicate<? super T> predicate)
LazyIterable
select
in interface LazyIterable<T>
select
in interface RichIterable<T>
select
in class AbstractLazyIterable<T>
public LazyIterable<T> reject(Predicate<? super T> predicate)
LazyIterable
reject
in interface LazyIterable<T>
reject
in interface RichIterable<T>
reject
in class AbstractLazyIterable<T>
predicate
- a Predicate
to use as the reject criteriaPredicate.accept(Object)
method to evaluate to falsepublic <V> LazyIterable<V> collect(Function<? super T,? extends V> function)
LazyIterable
collect
in interface LazyIterable<T>
collect
in interface RichIterable<T>
collect
in class AbstractLazyIterable<T>
public <V> LazyIterable<V> flatCollect(Function<? super T,? extends java.lang.Iterable<V>> function)
LazyIterable
flatCollect
in interface LazyIterable<T>
flatCollect
in interface RichIterable<T>
flatCollect
in class AbstractLazyIterable<T>
function
- The Function
to applyfunction
public <V> LazyIterable<V> collectIf(Predicate<? super T> predicate, Function<? super T,? extends V> function)
LazyIterable
collectIf
in interface LazyIterable<T>
collectIf
in interface RichIterable<T>
collectIf
in class AbstractLazyIterable<T>
public LazyIterable<T> take(int count)
LazyIterable
take
in interface LazyIterable<T>
take
in class AbstractLazyIterable<T>
public LazyIterable<T> drop(int count)
LazyIterable
drop
in interface LazyIterable<T>
drop
in class AbstractLazyIterable<T>
public LazyIterable<T> takeWhile(Predicate<? super T> predicate)
takeWhile
in interface LazyIterable<T>
takeWhile
in class AbstractLazyIterable<T>
OrderedIterable.takeWhile(Predicate)
public LazyIterable<T> dropWhile(Predicate<? super T> predicate)
dropWhile
in interface LazyIterable<T>
dropWhile
in class AbstractLazyIterable<T>
OrderedIterable.dropWhile(Predicate)
public LazyIterable<T> distinct()
LazyIterable
distinct
in interface LazyIterable<T>
distinct
in class AbstractLazyIterable<T>
public java.lang.Object[] toArray()
RichIterable
toArray
in interface RichIterable<T>
toArray
in class AbstractRichIterable<T>
Collection.toArray()
public int size()
RichIterable
size
in interface RichIterable<T>
size
in class AbstractLazyIterable<T>
public boolean isEmpty()
RichIterable
isEmpty
in interface RichIterable<T>
isEmpty
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 <P> boolean anySatisfyWith(Predicate2<? super T,? super P> predicate, P parameter)
RichIterable
anySatisfyWith
in interface RichIterable<T>
anySatisfyWith
in class AbstractRichIterable<T>
public <P> boolean allSatisfyWith(Predicate2<? super T,? super P> predicate, P parameter)
RichIterable
allSatisfyWith
in interface RichIterable<T>
allSatisfyWith
in class AbstractRichIterable<T>
public <P> boolean noneSatisfyWith(Predicate2<? super T,? super P> predicate, P parameter)
RichIterable
noneSatisfyWith
in interface RichIterable<T>
noneSatisfyWith
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 T getLast()
RichIterable
The order of Sets are not guaranteed (except for TreeSets and other Ordered Set implementations), so if you use this method, the last element could be any element from the Set.
getLast
in interface RichIterable<T>
getLast
in class AbstractLazyIterable<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 <P> T detectWith(Predicate2<? super T,? super P> predicate, P parameter)
RichIterable
Example using a Java 8 lambda expression:
Person person = people.detectWith((person, fullName) -> person.getFullName().equals(fullName), "John Smith");
Example using an anonymous inner class:
Person person = people.detectWith(new Predicate2<Person, String>() { public boolean accept(Person person, String fullName) { return person.getFullName().equals(fullName); } }, "John Smith");
detectWith
in interface RichIterable<T>
detectWith
in class AbstractRichIterable<T>
public java.util.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>
public <P> java.util.Optional<T> detectWithOptional(Predicate2<? super T,? super P> predicate, P parameter)
RichIterable
Example using a Java 8 lambda expression:
Optional<Person> person = people.detectWithOptional((person, fullName) -> person.getFullName().equals(fullName), "John Smith");
detectWithOptional
in interface RichIterable<T>
detectWithOptional
in class AbstractRichIterable<T>
Copyright © 2004–2018. All rights reserved.