@Immutable public class CollectIterable<T,V> extends AbstractLazyIterable<V>
| Constructor and Description |
|---|
CollectIterable(Iterable<T> newAdapted,
Function<? super T,? extends V> function) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
allSatisfy(Predicate<? super V> 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 V,? 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 V> predicate)
Returns true if the predicate evaluates to true for any element of the iterable.
|
<P> boolean |
anySatisfyWith(Predicate2<? super V,? super P> predicate,
P parameter)
Returns true if the predicate evaluates to true for any element of the collection, or return false.
|
V |
detect(Predicate<? super V> 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> V |
detectWith(Predicate2<? super V,? 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.
|
void |
each(Procedure<? super V> procedure)
The procedure is executed for each element in the iterable.
|
<P> void |
forEachWith(Procedure2<? super V,? 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 V> objectIntProcedure)
Iterates over the iterable passing each element and the current relative int index to the specified instance of
ObjectIntProcedure.
|
V |
getFirst()
Returns the first element of an iterable.
|
V |
getLast()
Returns the last element of an iterable.
|
double |
injectInto(double injectedValue,
DoubleObjectToDoubleFunction<? super V> f)
Returns the final double result of evaluating function using each element of the iterable and the previous evaluation
result as the parameters.
|
float |
injectInto(float injectedValue,
FloatObjectToFloatFunction<? super V> f)
Returns the final float result of evaluating function using each element of the iterable and the previous evaluation
result as the parameters.
|
int |
injectInto(int injectedValue,
IntObjectToIntFunction<? super V> f)
Returns the final int result of evaluating function using each element of the iterable and the previous evaluation
result as the parameters.
|
<IV> IV |
injectInto(IV injectedValue,
Function2<? super IV,? super V,? extends IV> f)
Returns the final result of evaluating function using each element of the iterable and the previous evaluation
result as the parameters.
|
long |
injectInto(long injectedValue,
LongObjectToLongFunction<? super V> f)
Returns the final long result of evaluating function using each element of the iterable and the previous evaluation
result as the parameters.
|
boolean |
isEmpty()
Returns true if this iterable has zero items.
|
Iterator<V> |
iterator() |
boolean |
noneSatisfy(Predicate<? super V> 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 V,? super P> predicate,
P parameter)
Returns true if the predicate evaluates to false for every element of the collection, or return false.
|
boolean |
notEmpty()
The English equivalent of !this.isEmpty()
|
int |
size()
Returns the number of items in this iterable.
|
Object[] |
toArray()
Converts this iterable to an array.
|
aggregateBy, aggregateInPlaceBy, asLazy, chunk, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, concatenate, distinct, drop, flatCollect, groupBy, groupByEach, groupByUniqueKey, into, partition, partitionWith, reject, rejectWith, select, selectInstancesOf, selectWith, take, tap, toArray, toStack, zip, zipWithIndexappendString, 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, makeString, makeString, makeString, max, max, maxBy, min, min, minBy, 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, zipWithIndexequals, getClass, hashCode, notify, notifyAll, wait, wait, waitappendString, 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, makeString, makeString, makeString, max, max, maxBy, min, min, minBy, 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, zipWithIndexforEachforEach, spliteratorpublic void each(Procedure<? super V> procedure)
RichIterableExample 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 V> objectIntProcedure)
InternalIterableExample 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<V>forEachWithIndex in class AbstractRichIterable<V>public <P> void forEachWith(Procedure2<? super V,? super P> procedure, P parameter)
InternalIterableExample 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<V>forEachWith in class AbstractRichIterable<V>public int size()
RichIterablesize in interface RichIterable<V>size in class AbstractLazyIterable<V>public boolean isEmpty()
RichIterableisEmpty in interface RichIterable<V>isEmpty in class AbstractLazyIterable<V>public boolean notEmpty()
RichIterablenotEmpty in interface RichIterable<V>notEmpty in class AbstractRichIterable<V>public Object[] toArray()
RichIterabletoArray in interface RichIterable<V>toArray in class AbstractRichIterable<V>Collection.toArray()public boolean anySatisfy(Predicate<? super V> predicate)
RichIterableanySatisfy in interface RichIterable<V>anySatisfy in class AbstractRichIterable<V>public <P> boolean anySatisfyWith(Predicate2<? super V,? super P> predicate, P parameter)
RichIterableanySatisfyWith in interface RichIterable<V>anySatisfyWith in class AbstractRichIterable<V>public boolean allSatisfy(Predicate<? super V> predicate)
RichIterableallSatisfy in interface RichIterable<V>allSatisfy in class AbstractRichIterable<V>public <P> boolean allSatisfyWith(Predicate2<? super V,? super P> predicate, P parameter)
RichIterableallSatisfyWith in interface RichIterable<V>allSatisfyWith in class AbstractRichIterable<V>public boolean noneSatisfy(Predicate<? super V> predicate)
RichIterablenoneSatisfy in interface RichIterable<V>noneSatisfy in class AbstractRichIterable<V>public <P> boolean noneSatisfyWith(Predicate2<? super V,? super P> predicate, P parameter)
RichIterablenoneSatisfyWith in interface RichIterable<V>noneSatisfyWith in class AbstractRichIterable<V>public V detect(Predicate<? super V> predicate)
RichIterableExample 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<V>detect in class AbstractRichIterable<V>public <P> V detectWith(Predicate2<? super V,? super P> predicate, P parameter)
RichIterableExample 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<V>detectWith in class AbstractRichIterable<V>public <IV> IV injectInto(IV injectedValue,
Function2<? super IV,? super V,? extends IV> f)
RichIterableinjectInto in interface RichIterable<V>injectInto in class AbstractRichIterable<V>public int injectInto(int injectedValue,
IntObjectToIntFunction<? super V> f)
RichIterableinjectInto in interface RichIterable<V>injectInto in class AbstractRichIterable<V>public long injectInto(long injectedValue,
LongObjectToLongFunction<? super V> f)
RichIterableinjectInto in interface RichIterable<V>injectInto in class AbstractRichIterable<V>public double injectInto(double injectedValue,
DoubleObjectToDoubleFunction<? super V> f)
RichIterableinjectInto in interface RichIterable<V>injectInto in class AbstractRichIterable<V>public float injectInto(float injectedValue,
FloatObjectToFloatFunction<? super V> f)
RichIterableinjectInto in interface RichIterable<V>injectInto in class AbstractRichIterable<V>public V 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<V>getFirst in interface RichIterable<V>getFirst in class AbstractLazyIterable<V>public V 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<V>getLast in class AbstractLazyIterable<V>Copyright © 2004–2016. All rights reserved.