@Immutable public class LazyIterableAdapter<T> extends AbstractLazyIterable<T>
Constructor and Description |
---|
LazyIterableAdapter(Iterable<T> newAdapted) |
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.
|
<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.
|
<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.
|
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.
|
void |
each(Procedure<? super T> procedure)
The procedure is executed for each element in the iterable.
|
<V> LazyIterable<V> |
flatCollect(Function<? super T,? extends 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 Collection<T>> |
into(R target)
Iterates over this iterable adding all elements into the target collection.
|
boolean |
isEmpty()
Returns true if this iterable has zero items.
|
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.
|
Object[] |
toArray()
Converts this iterable to an array.
|
aggregateBy, aggregateInPlaceBy, asLazy, chunk, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectInt, collectLong, collectShort, collectWith, concatenate, groupBy, groupByEach, groupByUniqueKey, partition, partitionWith, rejectWith, selectInstancesOf, selectWith, tap, toArray, toStack, zip, zipWithIndex
appendString, appendString, appendString, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, contains, containsAll, containsAllArguments, containsAllIterable, count, countWith, detectIfNone, detectWithIfNone, flatCollect, forEach, groupBy, groupByEach, groupByUniqueKey, injectInto, injectInto, injectInto, injectInto, injectInto, makeString, makeString, makeString, max, max, maxBy, min, min, minBy, notEmpty, reject, rejectWith, select, selectWith, sumByDouble, sumByFloat, sumByInt, sumByLong, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, toBag, toList, toMap, toSet, toSortedBag, toSortedBag, toSortedBagBy, toSortedList, toSortedList, toSortedListBy, toSortedMap, toSortedMap, toSortedSet, toSortedSet, toSortedSetBy, toString, zip, zipWithIndex
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, countWith, detectIfNone, detectWithIfNone, flatCollect, groupBy, groupByEach, groupByUniqueKey, injectInto, injectInto, injectInto, injectInto, injectInto, makeString, makeString, makeString, max, max, maxBy, min, min, minBy, notEmpty, reject, rejectWith, select, selectWith, sumByDouble, sumByFloat, sumByInt, sumByLong, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, 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 <R extends Collection<T>> R into(R target)
LazyIterable
into
in interface LazyIterable<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 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> distinct()
LazyIterable
distinct
in interface LazyIterable<T>
distinct
in class AbstractLazyIterable<T>
public 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 value(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 value(Person person, String fullName) { return person.getFullName().equals(fullName); } }, "John Smith");
detectWith
in interface RichIterable<T>
detectWith
in class AbstractRichIterable<T>
Copyright © 2004–2016. All rights reserved.