Class LazyIterableAdapter<T>
- All Implemented Interfaces:
Iterable<T>,InternalIterable<T>,LazyIterable<T>,RichIterable<T>
public class LazyIterableAdapter<T> extends AbstractLazyIterable<T>
-
Constructor Summary
Constructors Constructor Description LazyIterableAdapter(Iterable<T> newAdapted) -
Method Summary
Modifier and Type Method Description booleanallSatisfy(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> booleanallSatisfyWith(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.booleananySatisfy(Predicate<? super T> predicate)Returns true if the predicate evaluates to true for any element of the iterable.<P> booleananySatisfyWith(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.Tdetect(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.<P> TdetectWith(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> 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)voideach(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> voidforEachWith(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.voidforEachWithIndex(ObjectIntProcedure<? super T> objectIntProcedure)Iterates over the iterable passing each element and the current relative int index to the specified instance of ObjectIntProcedure.TgetFirst()Returns the first element of an iterable.TgetLast()Returns the last element of an iterable.<R extends Collection<T>>
Rinto(R target)Adds all the elements in this iterable to the specific target Collection.booleanisEmpty()Returns true if this iterable has zero items.Iterator<T>iterator()booleannoneSatisfy(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> booleannoneSatisfyWith(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.intsize()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)Object[]toArray()Converts this iterable to an array.Methods inherited from class org.eclipse.collections.impl.lazy.AbstractLazyIterable
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, zipWithIndexMethods inherited from class org.eclipse.collections.impl.AbstractRichIterable
appendString, appendString, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, contains, containsAll, containsAllArguments, containsAllIterable, count, countByEach, 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, toBiMap, toList, toMap, toSet, toSortedBag, toSortedBag, toSortedBagBy, toSortedListBy, toSortedMap, toSortedMap, toSortedMapBy, toSortedSet, toSortedSet, toSortedSetBy, toString, zip, zipWithIndexMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.eclipse.collections.api.RichIterable
aggregateBy, aggregateBy, appendString, appendString, appendString, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, contains, containsAll, containsAllArguments, containsAllIterable, containsBy, count, countBy, countBy, countByEach, countByEach, countByWith, countByWith, countWith, detectIfNone, detectWithIfNone, flatCollect, flatCollectBoolean, flatCollectByte, flatCollectChar, flatCollectDouble, flatCollectFloat, flatCollectInt, flatCollectLong, flatCollectShort, flatCollectWith, forEach, getAny, groupBy, groupByAndCollect, 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, toBiMap, toList, toMap, toMap, toSet, toSortedBag, toSortedBag, toSortedBagBy, toSortedList, toSortedList, toSortedListBy, toSortedMap, toSortedMap, toSortedMapBy, toSortedSet, toSortedSet, toSortedSetBy, toString, zip, zipWithIndex
-
Constructor Details
-
Method Details
-
each
Description copied from interface:RichIterableThe procedure is executed for each element in the iterable.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 ofInternalIterable.forEach(Procedure)that has a signature conflict withIterable.forEach(java.util.function.Consumer). -
forEachWithIndex
Description copied from interface:InternalIterableIterates 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()); } });- Specified by:
forEachWithIndexin interfaceInternalIterable<T>- Overrides:
forEachWithIndexin classAbstractRichIterable<T>
-
forEachWith
Description copied from interface:InternalIterableThe 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);- Specified by:
forEachWithin interfaceInternalIterable<T>- Overrides:
forEachWithin classAbstractRichIterable<T>
-
iterator
-
into
Description copied from interface:RichIterableAdds all the elements in this iterable to the specific target Collection.- Specified by:
intoin interfaceLazyIterable<T>- Specified by:
intoin interfaceRichIterable<T>- Overrides:
intoin classAbstractLazyIterable<T>
-
select
Description copied from interface:LazyIterableCreates a deferred iterable for selecting elements from the current iterable.- Specified by:
selectin interfaceLazyIterable<T>- Specified by:
selectin interfaceRichIterable<T>- Overrides:
selectin classAbstractLazyIterable<T>
-
reject
Description copied from interface:LazyIterableCreates a deferred iterable for rejecting elements from the current iterable.- Specified by:
rejectin interfaceLazyIterable<T>- Specified by:
rejectin interfaceRichIterable<T>- Overrides:
rejectin classAbstractLazyIterable<T>- Parameters:
predicate- aPredicateto use as the reject criteria- Returns:
- a RichIterable that contains elements that cause
Predicate.accept(Object)method to evaluate to false
-
collect
Description copied from interface:LazyIterableCreates a deferred iterable for collecting elements from the current iterable.- Specified by:
collectin interfaceLazyIterable<T>- Specified by:
collectin interfaceRichIterable<T>- Overrides:
collectin classAbstractLazyIterable<T>
-
flatCollect
Description copied from interface:LazyIterableCreates a deferred flattening iterable for the current iterable.- Specified by:
flatCollectin interfaceLazyIterable<T>- Specified by:
flatCollectin interfaceRichIterable<T>- Overrides:
flatCollectin classAbstractLazyIterable<T>- Parameters:
function- TheFunctionto apply- Returns:
- a new flattened collection produced by applying the given
function
-
collectIf
public <V> LazyIterable<V> collectIf(Predicate<? super T> predicate, Function<? super T,? extends V> function)Description copied from interface:LazyIterableCreates a deferred iterable for selecting and collecting elements from the current iterable.- Specified by:
collectIfin interfaceLazyIterable<T>- Specified by:
collectIfin interfaceRichIterable<T>- Overrides:
collectIfin classAbstractLazyIterable<T>
-
take
Description copied from interface:LazyIterableCreates a deferred take iterable for the current iterable using the specified count as the limit.- Specified by:
takein interfaceLazyIterable<T>- Overrides:
takein classAbstractLazyIterable<T>
-
drop
Description copied from interface:LazyIterableCreates a deferred drop iterable for the current iterable using the specified count as the limit.- Specified by:
dropin interfaceLazyIterable<T>- Overrides:
dropin classAbstractLazyIterable<T>
-
takeWhile
- Specified by:
takeWhilein interfaceLazyIterable<T>- Overrides:
takeWhilein classAbstractLazyIterable<T>- See Also:
OrderedIterable.takeWhile(Predicate)
-
dropWhile
- Specified by:
dropWhilein interfaceLazyIterable<T>- Overrides:
dropWhilein classAbstractLazyIterable<T>- See Also:
OrderedIterable.dropWhile(Predicate)
-
distinct
Description copied from interface:LazyIterableCreates a deferred distinct iterable to get distinct elements from the current iterable.- Specified by:
distinctin interfaceLazyIterable<T>- Overrides:
distinctin classAbstractLazyIterable<T>
-
toArray
Description copied from interface:RichIterableConverts this iterable to an array.- Specified by:
toArrayin interfaceRichIterable<T>- Overrides:
toArrayin classAbstractRichIterable<T>- See Also:
Collection.toArray()
-
size
public int size()Description copied from interface:RichIterableReturns the number of items in this iterable.- Specified by:
sizein interfaceRichIterable<T>- Overrides:
sizein classAbstractLazyIterable<T>
-
isEmpty
public boolean isEmpty()Description copied from interface:RichIterableReturns true if this iterable has zero items.- Specified by:
isEmptyin interfaceRichIterable<T>- Overrides:
isEmptyin classAbstractLazyIterable<T>
-
anySatisfy
Description copied from interface:RichIterableReturns 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.- Specified by:
anySatisfyin interfaceRichIterable<T>- Overrides:
anySatisfyin classAbstractRichIterable<T>
-
allSatisfy
Description copied from interface:RichIterableReturns true if the predicate evaluates to true for every element of the iterable or if the iterable is empty. Otherwise, returns false.- Specified by:
allSatisfyin interfaceRichIterable<T>- Overrides:
allSatisfyin classAbstractRichIterable<T>
-
noneSatisfy
Description copied from interface:RichIterableReturns true if the predicate evaluates to false for every element of the iterable or if the iterable is empty. Otherwise, returns false.- Specified by:
noneSatisfyin interfaceRichIterable<T>- Overrides:
noneSatisfyin classAbstractRichIterable<T>
-
anySatisfyWith
Description copied from interface:RichIterableReturns true if the predicate evaluates to true for any element of the collection, or return false. Returns false if the collection is empty.- Specified by:
anySatisfyWithin interfaceRichIterable<T>- Overrides:
anySatisfyWithin classAbstractRichIterable<T>
-
allSatisfyWith
Description copied from interface:RichIterableReturns true if the predicate evaluates to true for every element of the collection, or returns false.- Specified by:
allSatisfyWithin interfaceRichIterable<T>- Overrides:
allSatisfyWithin classAbstractRichIterable<T>
-
noneSatisfyWith
Description copied from interface:RichIterableReturns true if the predicate evaluates to false for every element of the collection, or return false. Returns true if the collection is empty.- Specified by:
noneSatisfyWithin interfaceRichIterable<T>- Overrides:
noneSatisfyWithin classAbstractRichIterable<T>
-
getFirst
Description copied from interface:RichIterableReturns 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.
- Specified by:
getFirstin interfaceLazyIterable<T>- Specified by:
getFirstin interfaceRichIterable<T>- Overrides:
getFirstin classAbstractLazyIterable<T>
-
getLast
Description copied from interface:RichIterableReturns the last element of an iterable. In the case of a List it is the element at the last index. In the case of any other Collection, it is the last 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 last element could be any element from the Set.
- Specified by:
getLastin interfaceRichIterable<T>- Overrides:
getLastin classAbstractLazyIterable<T>
-
detect
Description copied from interface:RichIterableReturns 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"));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"); } });- Specified by:
detectin interfaceRichIterable<T>- Overrides:
detectin classAbstractRichIterable<T>
-
detectWith
Description copied from interface:RichIterableReturns the first element that evaluates to true for the specified predicate2 and parameter, or null if none evaluate to true.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");- Specified by:
detectWithin interfaceRichIterable<T>- Overrides:
detectWithin classAbstractRichIterable<T>
-
detectOptional
Description copied from interface:RichIterableReturns 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"));- Specified by:
detectOptionalin interfaceRichIterable<T>- Overrides:
detectOptionalin classAbstractRichIterable<T>
-
detectWithOptional
Description copied from interface:RichIterableReturns the first element that evaluates to true for the specified predicate2 and parameter as an Optional.Example using a Java 8 lambda expression:
Optional<Person> person = people.detectWithOptional((person, fullName) -> person.getFullName().equals(fullName), "John Smith");- Specified by:
detectWithOptionalin interfaceRichIterable<T>- Overrides:
detectWithOptionalin classAbstractRichIterable<T>
-