@Immutable public abstract class AbstractLazyIterable<T> extends AbstractRichIterable<T> implements LazyIterable<T>
| Constructor and Description |
|---|
AbstractLazyIterable() |
| Modifier and Type | Method and Description |
|---|---|
<K,V> MapIterable<K,V> |
aggregateBy(Function<? super T,? extends K> groupBy,
Function0<? extends V> zeroValueFactory,
Function2<? super V,? super T,? extends V> nonMutatingAggregator)
Applies an aggregate function over the iterable grouping results into a map based on the specific groupBy function.
|
<K,V> MapIterable<K,V> |
aggregateInPlaceBy(Function<? super T,? extends K> groupBy,
Function0<? extends V> zeroValueFactory,
Procedure2<? super V,? super T> mutatingAggregator)
Applies an aggregate procedure over the iterable grouping results into a Map based on the specific groupBy function.
|
LazyIterable<T> |
asLazy()
Returns a lazy (deferred) iterable, most likely implemented by calling LazyIterate.adapt(this).
|
LazyIterable<RichIterable<T>> |
chunk(int size)
Creates a deferred chunking iterable.
|
<V> LazyIterable<V> |
collect(Function<? super T,? extends V> function)
Creates a deferred iterable for collecting elements from the current iterable.
|
LazyBooleanIterable |
collectBoolean(BooleanFunction<? super T> booleanFunction)
Returns a lazy BooleanIterable which will transform the underlying iterable data to boolean values based on the booleanFunction.
|
LazyByteIterable |
collectByte(ByteFunction<? super T> byteFunction)
Returns a lazy ByteIterable which will transform the underlying iterable data to byte values based on the byteFunction.
|
LazyCharIterable |
collectChar(CharFunction<? super T> charFunction)
Returns a lazy CharIterable which will transform the underlying iterable data to char values based on the charFunction.
|
LazyDoubleIterable |
collectDouble(DoubleFunction<? super T> doubleFunction)
Returns a lazy DoubleIterable which will transform the underlying iterable data to double values based on the doubleFunction.
|
LazyFloatIterable |
collectFloat(FloatFunction<? super T> floatFunction)
Returns a lazy FloatIterable which will transform the underlying iterable data to float values based on the floatFunction.
|
<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.
|
LazyIntIterable |
collectInt(IntFunction<? super T> intFunction)
Returns a lazy IntIterable which will transform the underlying iterable data to int values based on the intFunction.
|
LazyLongIterable |
collectLong(LongFunction<? super T> longFunction)
Returns a lazy LongIterable which will transform the underlying iterable data to long values based on the longFunction.
|
LazyShortIterable |
collectShort(ShortFunction<? super T> shortFunction)
Returns a lazy ShortIterable which will transform the underlying iterable data to short values based on the shortFunction.
|
<P,V> LazyIterable<V> |
collectWith(Function2<? super T,? super P,? extends V> function,
P parameter)
Same as
RichIterable.collect(Function) with a Function2 and specified parameter which is passed to the block. |
LazyIterable<T> |
concatenate(Iterable<T> iterable)
Creates a deferred iterable that will join this iterable with the specified iterable.
|
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.
|
<V> LazyIterable<V> |
flatCollect(Function<? super T,? extends Iterable<V>> function)
Creates a deferred flattening iterable for the current iterable.
|
T |
getFirst()
Returns the first element of an iterable.
|
T |
getLast()
Returns the last element of an iterable.
|
<V> Multimap<V,T> |
groupBy(Function<? super T,? extends V> function)
For each element of the iterable, the function is evaluated and the results of these evaluations are collected
into a new multimap, where the transformed value is the key and the original values are added to the same (or similar)
species of collection as the source iterable.
|
<V> Multimap<V,T> |
groupByEach(Function<? super T,? extends Iterable<V>> function)
Similar to
RichIterable.groupBy(Function), except the result of evaluating function will return a collection of keys
for each value. |
<V> MapIterable<V,T> |
groupByUniqueKey(Function<? super T,? extends V> function)
For each element of the iterable, the function is evaluated and he results of these evaluations are collected
into a new map, where the transformed value is the key.
|
<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.
|
PartitionMutableList<T> |
partition(Predicate<? super T> predicate)
Filters a collection into a PartitionedIterable based on the evaluation of the predicate.
|
<P> PartitionMutableList<T> |
partitionWith(Predicate2<? super T,? super P> predicate,
P parameter)
Filters a collection into a PartitionIterable based on the evaluation of the predicate.
|
LazyIterable<T> |
reject(Predicate<? super T> predicate)
Creates a deferred iterable for rejecting elements from the current iterable.
|
<P> LazyIterable<T> |
rejectWith(Predicate2<? super T,? super P> predicate,
P parameter)
Similar to
RichIterable.reject(Predicate), except with an evaluation parameter for the second generic argument in Predicate2. |
LazyIterable<T> |
select(Predicate<? super T> predicate)
Creates a deferred iterable for selecting elements from the current iterable.
|
<S> LazyIterable<S> |
selectInstancesOf(Class<S> clazz)
Returns all elements of the source collection that are instances of the Class
clazz. |
<P> LazyIterable<T> |
selectWith(Predicate2<? super T,? super P> predicate,
P parameter)
Similar to
RichIterable.select(Predicate), except with an evaluation parameter for the second generic argument in Predicate2. |
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> |
tap(Procedure<? super T> procedure)
Creates a deferred tap iterable.
|
<E> E[] |
toArray(E[] array)
Converts this iterable to an array using the specified target array, assuming the target array is as long
or longer than the iterable.
|
MutableStack<T> |
toStack() |
<S> LazyIterable<Pair<T,S>> |
zip(Iterable<S> that)
Creates a deferred zip iterable.
|
LazyIterable<Pair<T,Integer>> |
zipWithIndex()
Creates a deferred zipWithIndex iterable.
|
allSatisfy, allSatisfyWith, anySatisfy, anySatisfyWith, appendString, appendString, appendString, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, contains, containsAll, containsAllArguments, containsAllIterable, count, countWith, detect, detectIfNone, detectWith, detectWithIfNone, flatCollect, forEach, forEachWith, forEachWithIndex, groupBy, groupByEach, groupByUniqueKey, injectInto, injectInto, injectInto, injectInto, injectInto, makeString, makeString, makeString, max, max, maxBy, min, min, minBy, noneSatisfy, noneSatisfyWith, notEmpty, reject, rejectWith, select, selectWith, sumByDouble, sumByFloat, sumByInt, sumByLong, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, toArray, toBag, toList, toMap, toSet, toSortedBag, toSortedBag, toSortedBagBy, toSortedList, toSortedList, toSortedListBy, toSortedMap, toSortedMap, toSortedSet, toSortedSet, toSortedSetBy, toString, zip, zipWithIndexequals, getClass, hashCode, notify, notifyAll, wait, wait, waitallSatisfy, allSatisfyWith, anySatisfy, anySatisfyWith, appendString, appendString, appendString, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, contains, containsAll, containsAllArguments, containsAllIterable, count, countWith, detect, detectIfNone, detectWith, detectWithIfNone, each, flatCollect, groupBy, groupByEach, groupByUniqueKey, injectInto, injectInto, injectInto, injectInto, injectInto, makeString, makeString, makeString, max, max, maxBy, min, min, minBy, noneSatisfy, noneSatisfyWith, notEmpty, reject, rejectWith, select, selectWith, sumByDouble, sumByFloat, sumByInt, sumByLong, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, toArray, toBag, toList, toMap, toSet, toSortedBag, toSortedBag, toSortedBagBy, toSortedList, toSortedList, toSortedListBy, toSortedMap, toSortedMap, toSortedSet, toSortedSet, toSortedSetBy, toString, zip, zipWithIndexforEach, forEachWith, forEachWithIndexforEach, iterator, spliteratorpublic LazyIterable<T> asLazy()
RichIterableasLazy in interface RichIterable<T>asLazy in class AbstractRichIterable<T>public <R extends Collection<T>> R into(R target)
LazyIterableinto in interface LazyIterable<T>public <E> E[] toArray(E[] array)
RichIterabletoArray in interface RichIterable<T>toArray in class AbstractRichIterable<T>Collection.toArray(Object[])public int size()
RichIterablesize in interface RichIterable<T>public boolean isEmpty()
RichIterableisEmpty in interface RichIterable<T>isEmpty in class AbstractRichIterable<T>public T getFirst()
RichIterableThe 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>public T getLast()
RichIterableThe 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>public LazyIterable<T> select(Predicate<? super T> predicate)
LazyIterableselect in interface LazyIterable<T>select in interface RichIterable<T>public <P> LazyIterable<T> selectWith(Predicate2<? super T,? super P> predicate, P parameter)
RichIterableRichIterable.select(Predicate), except with an evaluation parameter for the second generic argument in Predicate2.
E.g. return a Collection of Person elements where the person has an age greater than or equal to 18 years
Example using a Java 8 lambda expression:
RichIterable<Person> selected =
people.selectWith((Person person, Integer age) -> person.getAge() >= age, Integer.valueOf(18));
Example using an anonymous inner class:
RichIterable<Person> selected =
people.selectWith(new Predicate2<Person, Integer>()
{
public boolean accept(Person person, Integer age)
{
return person.getAge() >= age;
}
}, Integer.valueOf(18));
selectWith in interface LazyIterable<T>selectWith in interface RichIterable<T>predicate - a Predicate2 to use as the select criteriaparameter - a parameter to pass in for evaluation of the second argument P in predicateRichIterable.select(Predicate)public LazyIterable<T> reject(Predicate<? super T> predicate)
LazyIterablereject in interface LazyIterable<T>reject in interface RichIterable<T>predicate - a Predicate to use as the reject criteriaPredicate.accept(Object) method to evaluate to falsepublic <P> LazyIterable<T> rejectWith(Predicate2<? super T,? super P> predicate, P parameter)
RichIterableRichIterable.reject(Predicate), except with an evaluation parameter for the second generic argument in Predicate2.
E.g. return a Collection of Person elements where the person has an age greater than or equal to 18 years
Example using a Java 8 lambda expression:
RichIterable<Person> rejected =
people.rejectWith((Person person, Integer age) -> person.getAge() < age, Integer.valueOf(18));
Example using an anonymous inner class:
MutableList<Person> rejected =
people.rejectWith(new Predicate2<Person, Integer>()
{
public boolean accept(Person person, Integer age)
{
return person.getAge() < age;
}
}, Integer.valueOf(18));
rejectWith in interface LazyIterable<T>rejectWith in interface RichIterable<T>predicate - a Predicate2 to use as the select criteriaparameter - a parameter to pass in for evaluation of the second argument P in predicateRichIterable.select(Predicate)public PartitionMutableList<T> partition(Predicate<? super T> predicate)
RichIterableExample using a Java 8 lambda expression:
PartitionIterable<Person> newYorkersAndNonNewYorkers =
people.partition(person -> person.getAddress().getState().getName().equals("New York"));
Example using an anonymous inner class:
PartitionIterable<Person> newYorkersAndNonNewYorkers =
people.partition(new Predicate<Person>()
{
public boolean accept(Person person)
{
return person.getAddress().getState().getName().equals("New York");
}
});
partition in interface RichIterable<T>public <P> PartitionMutableList<T> partitionWith(Predicate2<? super T,? super P> predicate, P parameter)
RichIterableExample using a Java 8 lambda expression:
PartitionIterable<Person>> newYorkersAndNonNewYorkers =
people.partitionWith((Person person, String state) -> person.getAddress().getState().getName().equals(state), "New York");
Example using an anonymous inner class:
PartitionIterable<Person>> newYorkersAndNonNewYorkers =
people.partitionWith(new Predicate2<Person, String>()
{
public boolean accept(Person person, String state)
{
return person.getAddress().getState().getName().equals(state);
}
}, "New York");
partitionWith in interface RichIterable<T>public <S> LazyIterable<S> selectInstancesOf(Class<S> clazz)
RichIterableclazz.selectInstancesOf in interface LazyIterable<T>selectInstancesOf in interface RichIterable<T>public <V> LazyIterable<V> collect(Function<? super T,? extends V> function)
LazyIterablecollect in interface LazyIterable<T>collect in interface RichIterable<T>public LazyBooleanIterable collectBoolean(BooleanFunction<? super T> booleanFunction)
LazyIterablecollectBoolean in interface LazyIterable<T>collectBoolean in interface RichIterable<T>public LazyByteIterable collectByte(ByteFunction<? super T> byteFunction)
LazyIterablecollectByte in interface LazyIterable<T>collectByte in interface RichIterable<T>public LazyCharIterable collectChar(CharFunction<? super T> charFunction)
LazyIterablecollectChar in interface LazyIterable<T>collectChar in interface RichIterable<T>public LazyDoubleIterable collectDouble(DoubleFunction<? super T> doubleFunction)
LazyIterablecollectDouble in interface LazyIterable<T>collectDouble in interface RichIterable<T>public LazyFloatIterable collectFloat(FloatFunction<? super T> floatFunction)
LazyIterablecollectFloat in interface LazyIterable<T>collectFloat in interface RichIterable<T>public LazyIntIterable collectInt(IntFunction<? super T> intFunction)
LazyIterablecollectInt in interface LazyIterable<T>collectInt in interface RichIterable<T>public LazyLongIterable collectLong(LongFunction<? super T> longFunction)
LazyIterablecollectLong in interface LazyIterable<T>collectLong in interface RichIterable<T>public LazyShortIterable collectShort(ShortFunction<? super T> shortFunction)
LazyIterablecollectShort in interface LazyIterable<T>collectShort in interface RichIterable<T>public <P,V> LazyIterable<V> collectWith(Function2<? super T,? super P,? extends V> function, P parameter)
RichIterableRichIterable.collect(Function) with a Function2 and specified parameter which is passed to the block.
Example using a Java 8 lambda expression:
RichIterable<Integer> integers =
Lists.mutable.with(1, 2, 3).collectWith((each, parameter) -> each + parameter, Integer.valueOf(1));
Example using an anonymous inner class:
Function2<Integer, Integer, Integer> addParameterFunction =
new Function2<Integer, Integer, Integer>()
{
public Integer value(Integer each, Integer parameter)
{
return each + parameter;
}
};
RichIterable<Integer> integers =
Lists.mutable.with(1, 2, 3).collectWith(addParameterFunction, Integer.valueOf(1));
collectWith in interface LazyIterable<T>collectWith in interface RichIterable<T>function - A Function2 to use as the collect transformation functionparameter - A parameter to pass in for evaluation of the second argument P in functionRichIterable that contains the transformed elements returned by Function2.value(Object, Object)RichIterable.collect(Function)public <V> LazyIterable<V> flatCollect(Function<? super T,? extends Iterable<V>> function)
LazyIterableflatCollect in interface LazyIterable<T>flatCollect in interface RichIterable<T>function - The Function to applyfunctionpublic LazyIterable<T> concatenate(Iterable<T> iterable)
LazyIterableconcatenate in interface LazyIterable<T>public <V> LazyIterable<V> collectIf(Predicate<? super T> predicate, Function<? super T,? extends V> function)
LazyIterablecollectIf in interface LazyIterable<T>collectIf in interface RichIterable<T>public LazyIterable<T> take(int count)
LazyIterabletake in interface LazyIterable<T>public LazyIterable<T> drop(int count)
LazyIterabledrop in interface LazyIterable<T>public LazyIterable<T> distinct()
LazyIterabledistinct in interface LazyIterable<T>public MutableStack<T> toStack()
public <V> Multimap<V,T> groupBy(Function<? super T,? extends V> function)
RichIterableExample using a Java 8 method reference:
Multimap<String, Person> peopleByLastName =
people.groupBy(Person::getLastName);
Example using an anonymous inner class:
Multimap<String, Person> peopleByLastName =
people.groupBy(new Function<Person, String>()
{
public String valueOf(Person person)
{
return person.getLastName();
}
});
groupBy in interface RichIterable<T>public <V> Multimap<V,T> groupByEach(Function<? super T,? extends Iterable<V>> function)
RichIterableRichIterable.groupBy(Function), except the result of evaluating function will return a collection of keys
for each value.groupByEach in interface RichIterable<T>public <V> MapIterable<V,T> groupByUniqueKey(Function<? super T,? extends V> function)
RichIterablegroupByUniqueKey in interface RichIterable<T>RichIterable.groupBy(Function)public <S> LazyIterable<Pair<T,S>> zip(Iterable<S> that)
LazyIterablezip in interface LazyIterable<T>zip in interface RichIterable<T>S - the type of the second half of the returned pairsthat - The RichIterable providing the second half of each result pairRichIterable containing pairs consisting of corresponding elements of this RichIterable and that. The length of the returned RichIterable is the minimum of the lengths of
this RichIterable and that.public LazyIterable<Pair<T,Integer>> zipWithIndex()
LazyIterablezipWithIndex in interface LazyIterable<T>zipWithIndex in interface RichIterable<T>RichIterable containing pairs consisting of all elements of this RichIterable
paired with their index. Indices start at 0.RichIterable.zip(Iterable)public LazyIterable<RichIterable<T>> chunk(int size)
LazyIterablechunk in interface LazyIterable<T>chunk in interface RichIterable<T>size - the number of elements per chunkRichIterable containing RichIterables of size size, except the last will be
truncated if the elements don't divide evenly.public LazyIterable<T> tap(Procedure<? super T> procedure)
LazyIterabletap in interface LazyIterable<T>tap in interface RichIterable<T>RichIterable.each(Procedure),
InternalIterable.forEach(Procedure)public <K,V> MapIterable<K,V> aggregateInPlaceBy(Function<? super T,? extends K> groupBy, Function0<? extends V> zeroValueFactory, Procedure2<? super V,? super T> mutatingAggregator)
RichIterableaggregateInPlaceBy in interface RichIterable<T>public <K,V> MapIterable<K,V> aggregateBy(Function<? super T,? extends K> groupBy, Function0<? extends V> zeroValueFactory, Function2<? super V,? super T,? extends V> nonMutatingAggregator)
RichIterableaggregateBy in interface RichIterable<T>Copyright © 2004–2016. All rights reserved.