public final class Lambda extends Object
| Modifier and Type | Field and Description |
|---|---|
static int |
DESCENDING |
static int |
IGNORE_CASE |
| Modifier and Type | Method and Description |
|---|---|
static <T> T |
aggregate(Object iterable,
Aggregator<T> aggregator)
Aggregates the items in the given iterable using the given
Aggregator. |
static <T,A> T |
aggregate(Object iterable,
Aggregator<T> aggregator,
A argument)
For each item in the given iterable collects the value defined by the given argument and
then aggregates them iterable using the given
Aggregator. |
static <T,A> T |
aggregateFrom(Iterable<T> iterable,
Aggregator<A> aggregator)
Returns a lambda function defined as:
aggregateFrom : (aggregator, iterable) => lambda : (convert : object => object) => object
It is then possibly to curry this function by selecting the convert function that defines how each item must be converted in the object to be aggregated.
|
static <T,A> T |
aggregateFrom(Iterable<T> iterable,
Class<?> clazz,
Aggregator<A> aggregator)
Returns a lambda function defined as:
aggregateFrom : (aggregator, iterable) => lambda : (convert : object => object) => object
It is then possibly to curry this function by selecting the convert function that defines how each item must be converted in the object to be aggregated.
|
static <T> Argument<T> |
argument(T argumentPlaceholder)
Returns the actual argument of the methods invocation sequence defined through the
on(Class) method. |
static <F> Converter<F,Map.Entry<String,Object>> |
as(Object argument)
Creates a converter that projects the value of the argument of an object using as alias
the argument property name as defined by
Argument.getInkvokedPropertyName() |
static <F> Converter<F,Map.Entry<String,Object>> |
as(String alias,
Object argument)
Creates a converter that projects the value of the argument of an object using as the given alias
|
static Number |
avg(Object iterable)
Calculates the average of the items in the given iterable of Numbers or the iterable itself if it actually is already a single number.
|
static <T> T |
avg(Object iterable,
T argument)
Calculates the average of the property values of the items in the given iterable defined by the given argument.
|
static <T> T |
avgFrom(Iterable<T> iterable)
Returns a lambda function defined as:
avgFrom : (avg, iterable) => lambda : (convert : object => number) => number
It is then possibly to curry this function by selecting the convert function that defines of each item must be converted in a number.
|
static <T> T |
avgFrom(Iterable<T> iterable,
Class<?> clazz)
Returns a lambda function defined as:
avgFrom : (avg, iterable) => lambda : (convert : object => number) => number
It is then possibly to curry this function by selecting the convert function that defines of each item must be converted in a number.
|
static <T> ArgumentGroupCondition<T> |
by(T argument)
Creates a GroupCondition that allows to group items based on the value they have on a given argument
|
static Closure |
closure()
Creates a generic (not typed) closure and binds it to the current thread
|
static <A> Closure1<A> |
closure(Class<A> type1)
Creates a closure with a single free variable and binds it to the current thread
|
static <A,B> Closure2<A,B> |
closure(Class<A> type1,
Class<B> type2)
Creates a closure with two free variables and binds it to the current thread
|
static <A,B,C> Closure3<A,B,C> |
closure(Class<A> type1,
Class<B> type2,
Class<C> type3)
Creates a closure with three free variables and binds it to the current thread
|
static <A,B,C,D> Closure4<A,B,C,D> |
closure(Class<A> type1,
Class<B> type2,
Class<C> type3,
Class<D> type4)
Creates a closure with four free variables and binds it to the current thread
|
static <T> List<? extends T> |
collect(Object iterable)
Collects the items in the given iterable putting them in a List.
|
static <T> List<T> |
collect(Object iterable,
T argument)
For each item in the given iterable collects the value defined by the given argument and put them in a List.
|
static <F,T> List<T> |
convert(Object iterable,
Converter<F,T> converter)
Converts all the object in the iterable using the given
Converter. |
static <F,T> Iterator<T> |
convertIterator(Object iterable,
Converter<F,T> converter)
Converts all the object in the iterable using the given
Converter. |
static <K,F,T> Map<K,T> |
convertMap(Map<K,F> map,
Converter<F,T> converter)
Converts all the values in the map using the given
Converter. |
static <K,F,T> Map<K,T> |
convertMap(Map<K,F> map,
T argument)
Converts all the values in the map extracting the property defined by the given argument.
|
static <T> Map<T,Integer> |
count(Object iterable)
Counts the number of occurrencies of the objects in the given iterable
Actually it handles also Maps, Arrays and Iterator by collecting their values.
|
static <A> Map<A,Integer> |
count(Object iterable,
A argument)
Counts the number of occurrencies of the argument's value in the objects of the given iterable
Actually it handles also Maps, Arrays and Iterator by collecting their values.
|
static <T> ClosureResult<T> |
delayedClosure(DelayedClosure<T> delayedClosure)
Returns the result of the invocation of the method that uses the given delayed closure
|
static void |
enableJitting(boolean enable)
Enable or disable the JIT optimization of lambdaj's arguments.
|
static boolean |
exists(Object iterable,
org.hamcrest.Matcher<?> matcher)
Returns true if the given iterable contains at least an item that matches the given hamcrest Matcher
Actually it handles also Maps, Arrays and Iterator by collecting their values.
|
static <F,T> List<T> |
extract(Object iterable,
T argument)
Converts all the object in the iterable extracting the property defined by the given argument.
|
static <F,T> Iterator<T> |
extractIterator(Object iterable,
T argument)
Converts all the object in the iterable extracting the property defined by the given argument.
|
static <F,T> List<T> |
extractProperty(Object iterable,
String propertyName)
Converts all the object in the iterable extracting the named property.
|
static List<String> |
extractString(Object iterable)
Converts all the object in the iterable in its String representation.
|
static <T> List<T> |
filter(org.hamcrest.Matcher<?> matcher,
Iterable<T> iterable)
Filters all the objects in the given iterable that match the given hamcrest Matcher
|
static <T> List<T> |
filter(org.hamcrest.Matcher<?> matcher,
T... array)
Filters all the objects in the given array that match the given hamcrest Matcher
|
static <T> List<T> |
flatten(Object iterable)
Flattens the given iterable by recursively descending through its nested Collections
and create a flat List of all of the leaves.
|
static <T> T |
forEach(Class<T> clazz,
T... array)
Transforms an array of Ts in a single object having the same methods of a single instance of T.
|
static <T> T |
forEach(Iterable<? extends T> iterable)
Transforms a collection of Ts in a single object having the same methods of a single instance of T.
|
static <T> T |
forEach(Iterable<? extends T> iterable,
Class<T> clazz)
Transforms a collection of Ts in a single object having the same methods of a single instance of T.
|
static <T> T |
forEach(Iterator<? extends T> iterator)
Transforms a collection of Ts in a single object having the same methods of a single instance of T.
|
static <T> T |
forEach(Iterator<? extends T> iterator,
Class<T> clazz)
Transforms an iterator of Ts in a single object having the same methods of a single instance of T.
|
static <T> T |
forEach(T... array)
Transforms an array of Ts in a single object having the same methods of a single instance of T.
|
static <T> Group<T> |
group(Iterable<T> iterable,
Collection<? extends GroupCondition<?>> conditions)
Organizes the given list of items in (hierarchy of) groups based on the given grouping conditions
|
static <T> Group<T> |
group(Iterable<T> iterable,
GroupCondition<?>... conditions)
Organizes the given list of items in (hierarchy of) groups based on the given grouping conditions
|
static <T> Group<T> |
group(Iterable<T> iterable,
String... groupers)
Organizes the given list of items in (hierarchy of) groups based on the values they have on the named JavaBean proprties
|
static <T,A> HasArgumentWithValue<T,A> |
having(A argument,
org.hamcrest.Matcher<?> matcher)
Creates an hamcrest matcher that is evalued to true if the value of the given argument satisfies
the condition defined by the passed matcher.
|
static <T> HasArgumentWithValue<T,Boolean> |
having(Boolean argument)
Creates an hamcrest matcher that is evalued to true accordingly to the value of the passed argument
|
static <F,T> Map<T,F> |
index(Object iterable,
T argument)
Indexes the objects in the given iterable based on the value of their argument.
|
static String |
join(Object iterable)
Joins all the object in the given iterable by concatenating all their String representation.
|
static String |
join(Object iterable,
String separator)
Joins all the object in the given iterable by concatenating all their String representation.
|
static <T> T |
joinFrom(Iterable<T> iterable)
Returns a lambda function defined as:
joinFrom : (concat, iterable) => lambda : (convert : object => object) => string
It is then possibly to curry this function by selecting the convert function that defines of each item must be converted in a String.
|
static <T> T |
joinFrom(Iterable<T> iterable,
Class<?> clazz)
Returns a lambda function defined as:
joinFrom : (concat, iterable) => lambda : (convert : object => object) => string
It is then possibly to curry this function by selecting the convert function that defines of each item must be converted in a String.
|
static <T> T |
joinFrom(Iterable<T> iterable,
Class<?> clazz,
String separator)
Returns a lambda function defined as:
joinFrom : (concat, iterable) => lambda : (convert : object => object) => string
It is then possibly to curry this function by selecting the convert function that defines of each item must be converted in a String.
|
static <T> T |
joinFrom(Iterable<T> iterable,
String separator)
Returns a lambda function defined as:
joinFrom : (concat, iterable) => lambda : (convert : object => object) => string
It is then possibly to curry this function by selecting the convert function that defines of each item must be converted in a String.
|
static <F,T> Map<T,F> |
map(Object iterable,
Converter<F,T> converter)
Maps the objects in the given iterable on the value extracted using the given
Converter. |
static <T> T |
max(Object iterable)
Finds the maximum item in the given iterable.
|
static <T> T |
max(Object iterable,
T argument)
Finds the maximum item in the given iterable defined by the given argument.
|
static <T> T |
maxFrom(Iterable<T> iterable)
Returns a lambda function defined as:
maxFrom : (max, iterable) => lambda : (convert : object => object) => object
It is then possibly to curry this function by selecting the convert function that defines how each item
must be converted in the object of which a maximum value needs to be found.
|
static <T> T |
maxFrom(Iterable<T> iterable,
Class<?> clazz)
Returns a lambda function defined as:
maxFrom : (max, iterable) => lambda : (convert : object => object) => object
It is then possibly to curry this function by selecting the convert function that defines how each item
must be converted in the object of which a maximum value needs to be found.
|
static <T> T |
min(Object iterable)
Finds the minimum item in the given iterable.
|
static <T> T |
min(Object iterable,
T argument)
Finds the minimum item in the given iterable defined by the given argument.
|
static <T> T |
minFrom(Iterable<T> iterable)
Returns a lambda function defined as:
minFrom : (min, iterable) => lambda : (convert : object => object) => object
It is then possibly to curry this function by selecting the convert function that defines how each item
must be converted in the object of which a minimum value needs to be found.
|
static <T> T |
minFrom(Iterable<T> iterable,
Class<?> clazz)
Returns a lambda function defined as:
minFrom : (min, iterable) => lambda : (convert : object => object) => object
It is then possibly to curry this function by selecting the convert function that defines how each item
must be converted in the object of which a minimum value needs to be found.
|
static <T> T |
of(Class<T> closedClass)
Binds a free variable of the given class to the active closure that is the last one created in the current thread.
|
static <T> T |
of(T closed)
Binds an object to the active closure that is the last one created in the current thread.
|
static <T> T |
of(T closed,
Class<T> closedClass)
Binds an object to the active closure that is the last one created in the current thread.
|
static <T> T |
on(Class<T> clazz)
Constructs a proxy object that mocks the given Class registering all the subsequent invocations on the object.
|
static <T> List<T> |
project(Object iterable,
Class<T> targetClass,
Object... arguments)
Converts the objects in the given iterable in objects of the given target Class.
|
static <F> List<Map<String,Object>> |
project(Object iterable,
Converter<F,Map.Entry<String,Object>>... projectors)
Projects the objects in the given iterable by converting each of them in a set of key/value pairs.
|
static <T> void |
registerFinalClassArgumentCreator(Class<T> clazz,
FinalClassArgumentCreator<T> creator)
Register a custom argument creator factory for an unknown final class
|
static <T> List<T> |
select(Iterable<T> iterable,
org.hamcrest.Matcher<?> matcher)
Selects all the objects in the given iterable that match the given hamcrest Matcher
|
static <T> List<T> |
select(Iterator<T> iterator,
org.hamcrest.Matcher<?> matcher)
Selects all the objects in the given iterator that match the given hamcrest Matcher
|
static <T> List<T> |
select(Object iterable,
org.hamcrest.Matcher<?> matcher)
Selects all the objects in the given iterable that match the given hamcrest Matcher
Actually it handles also Maps, Arrays and Iterator by collecting their values.
|
static <T> Collection<T> |
selectDistinct(Iterable<T> iterable)
Filters away all the duplicated items in the given iterable.
|
static <T> Collection<T> |
selectDistinct(Object iterable)
Filters away all the duplicated items in the given iterable.
|
static <T> Collection<T> |
selectDistinct(Object iterable,
Comparator<T> comparator)
Filters away all the duplicated items in the given iterable based on the given comparator.
|
static <T> Collection<T> |
selectDistinct(Object iterable,
String propertyName)
Selects all the items in the given iterable having a different value in the named property.
|
static <T,A> Collection<T> |
selectDistinctArgument(Object iterable,
A argument)
Selects all the items in the given iterable having a different value on the given argument defined using the on method.
|
static <T> T |
selectFirst(Object iterable,
org.hamcrest.Matcher<?> matcher)
Selects the first object in the given iterable that matches the given hamcrest Matcher
Actually it handles also Maps, Arrays and Iterator by collecting their values.
|
static <T> Iterator<T> |
selectIterator(Object iterable,
org.hamcrest.Matcher<?> matcher)
Selects all the objects in the given iterable that match the given hamcrest Matcher
Actually it handles also Maps, Arrays and Iterator by collecting their values.
|
static <T,A> T |
selectMax(Object iterable,
A argument)
Selects the item in the given iterable having the highest value on the given argument defined using the on method.
|
static <T,A> T |
selectMin(Object iterable,
A argument)
Selects the item in the given iterable having the lowest value on the given argument defined using the on method.
|
static <T> T |
selectUnique(Object iterable,
org.hamcrest.Matcher<?> matcher)
Selects the unique object in the given iterable that matches the given hamcrest Matcher
Actually it handles also Maps, Arrays and Iterator by collecting their values.
|
static <T,A> List<T> |
sort(Object iterable,
A argument,
Comparator<A> comparator)
Sorts all the items in the given iterable on the respective values of the given argument comparing them with the given comparator.
|
static <T> List<T> |
sort(Object iterable,
Object argument)
Sorts all the items in the given iterable on the respective values of the given argument.
|
static <T> List<T> |
sort(Object iterable,
Object argument,
int option)
Sorts all the items in the given iterable on the respective values of the given argument.
|
static Number |
sum(Object iterable)
Sums the items in the given iterable of Numbers or the iterable itself if it actually is already a single number.
|
static <T> T |
sum(Object iterable,
T argument)
Sums the property values of the items in the given iterable defined by the given argument.
|
static <T> T |
sumFrom(Iterable<T> iterable)
Returns a lambda function defined as:
sumFrom : (+, iterable) => lambda : (convert : object => number) => number
It is then possibly to curry this function by selecting the convert function that defines of each item must be converted in a number.
|
static <T> T |
sumFrom(Iterable<T> iterable,
Class<?> clazz)
Returns a lambda function defined as:
sumFrom : (+, iterable) => lambda : (convert : object => number) => number
It is then possibly to curry this function by selecting the convert function that defines of each item must be converted in a number.
|
static <T> T |
var(Class<T> clazz)
Defines a free variable of the given Class for the currently active closure
|
public static final int DESCENDING
public static final int IGNORE_CASE
public static void enableJitting(boolean enable)
enable - True to enable the JIT optimization, false to disable itpublic static <T> void registerFinalClassArgumentCreator(Class<T> clazz, FinalClassArgumentCreator<T> creator)
T - clazz - The class for which this factory should be usedcreator - The argument factorypublic static <T> T on(Class<T> clazz)
clazz - The class of the object to be mockedpublic static <T> Argument<T> argument(T argumentPlaceholder)
on(Class) method.public static <T> T forEach(Iterable<? extends T> iterable)
List<Person> personInFamily = asList(new Person("Domenico"), new Person("Mario"), new Person("Irma"));
forEach(personInFamily).setLastName("Fusco");
The actual class of T is inferred from the class of the first iterable's item, but you can
specify a particular class by using the overloaded method.T - The type of the items in the iterableiterable - The iterable to be transformedIllegalArgumentException - if the iterable is null or emptypublic static <T> T forEach(Iterator<? extends T> iterator)
T - The type of the items in the iterableiterator - The iterator to be transformedIllegalArgumentException - if the iterable is null or emptypublic static <T> T forEach(Iterable<? extends T> iterable, Class<T> clazz)
List<Person> personInFamily = asList(new Person("Domenico"), new Person("Mario"), new Person("Irma"));
forEach(personInFamily, Person.class).setLastName("Fusco");
The given class represents the proxied by the returned object, so it should be a superclass of all the objects in the iterable.
This overloaded version should be always used when it is not insured that the given iterable is null or empty.T - The type of the items in the iterableiterable - The iterable to be transformedclazz - The class proxied by the returned objectpublic static <T> T forEach(Iterator<? extends T> iterator, Class<T> clazz)
T - The type of the items in the iteratoriterator - The iterator to be transformedclazz - The class proxied by the returned objectIllegalArgumentException - if the iterator is null or emptypublic static <T> T forEach(T... array)
T - The type of the items in the arrayarray - The array to be transformedpublic static <T> T forEach(Class<T> clazz, T... array)
T - The type of the items in the arrayclazz - The class proxied by the returned objectarray - The array to be transformedpublic static <T> List<T> flatten(Object iterable)
iterable - The iterable to be flattenedpublic static <T> List<? extends T> collect(Object iterable)
forEach(Iterable).iterable - The iterable of which the items should be collectedIllegalArgumentException - if the iterable is not an Iterable or a Mappublic static <T> List<T> collect(Object iterable, T argument)
List<Person> myFriends = asList(new Person("Biagio", 39), new Person("Luca", 29), new Person("Celestino", 29));
List<Integer> ages = collect(meAndMyFriends, on(Person.class).getAge());
extracts the ages of all the Persons in the list and put them in a List of Integer.
Actually it handles also Maps, Arrays and Iterator by collecting their values.
Note that this method accepts an Object in order to be used in conjunction with the forEach(Iterable).iterable - The iterable of which the items should be collectedargument - An argument defined using the on(Class) methodRuntimeException - if the iterable is not an Iterable or a Mappublic static <T> List<T> sort(Object iterable, Object argument)
forEach(Iterable).iterable - The iterable of objects to be sortedargument - An argument defined using the on(Class) methodpublic static <T> List<T> sort(Object iterable, Object argument, int option)
forEach(Iterable).iterable - The iterable of objects to be sortedargument - An argument defined using the on(Class) methodoption - Sorting option e.g.: DESCENDING + IGNORE_CASEpublic static <T,A> List<T> sort(Object iterable, A argument, Comparator<A> comparator)
forEach(Iterable).iterable - The iterable of objects to be sortedargument - An argument defined using the on(Class) methodcomparator - The comparator to determine the order of the list. A null value indicates that the elements' natural ordering should be usedpublic static <T> Map<T,Integer> count(Object iterable)
forEach(Iterable).iterable - The iterable of objects to be countedpublic static <A> Map<A,Integer> count(Object iterable, A argument)
forEach(Iterable).iterable - The iterable of objects' arguments to be countedargument - An argument defined using the on(Class) methodpublic static <T> List<T> filter(org.hamcrest.Matcher<?> matcher, Iterable<T> iterable)
matcher - The hamcrest Matcher used to filter the given iterableiterable - The iterable of objects to be filteredpublic static <T> List<T> filter(org.hamcrest.Matcher<?> matcher, T... array)
matcher - The hamcrest Matcher used to filter the given arrayarray - The array of objects to be filteredpublic static <T> List<T> select(Iterator<T> iterator, org.hamcrest.Matcher<?> matcher)
iterator - The iterator of objects to be filteredmatcher - The hamcrest Matcher used to filter the given iterablepublic static <T> List<T> select(Iterable<T> iterable, org.hamcrest.Matcher<?> matcher)
iterable - The iterable of objects to be filteredmatcher - The hamcrest Matcher used to filter the given iterablepublic static <T> List<T> select(Object iterable, org.hamcrest.Matcher<?> matcher)
forEach(Iterable).iterable - The iterable of objects to be filteredmatcher - The hamcrest Matcher used to filter the given iterablepublic static <T> Iterator<T> selectIterator(Object iterable, org.hamcrest.Matcher<?> matcher)
forEach(Iterable).
Unlike the method select(Iterable, Matcher) this one doesn't build a new collection, and the
selection is done while iterating the returned iterator.iterable - The iterable of objects to be filteredmatcher - The hamcrest Matcher used to filter the given iterableConverterpublic static <T> T selectUnique(Object iterable, org.hamcrest.Matcher<?> matcher)
forEach(Iterable).iterable - The iterable of objects to be filteredmatcher - The hamcrest Matcher used to filter the given iterableNotUniqueItemException - if there is more than one object that matches the given hamcrest Matcherpublic static boolean exists(Object iterable, org.hamcrest.Matcher<?> matcher)
forEach(Iterable).iterable - The iterable of objects to be filteredmatcher - The hamcrest Matcher used to filter the given iterablepublic static <T> T selectFirst(Object iterable, org.hamcrest.Matcher<?> matcher)
forEach(Iterable).iterable - The iterable of objects to be filteredmatcher - The hamcrest Matcher used to filter the given iterablepublic static <T> Collection<T> selectDistinct(Iterable<T> iterable)
iterable - The iterable of objects to be filteredpublic static <T> Collection<T> selectDistinct(Object iterable)
forEach(Iterable).iterable - The iterable of objects to be filteredpublic static <T> Collection<T> selectDistinct(Object iterable, String propertyName)
forEach(Iterable).iterable - The iterable of objects to be filteredpropertyName - The name of the item's property on which the item must have no duplicated valuepublic static <T,A> Collection<T> selectDistinctArgument(Object iterable, A argument)
forEach(Iterable).iterable - The iterable of objects to be filteredargument - An argument defined using the on(Class) methodpublic static <T> Collection<T> selectDistinct(Object iterable, Comparator<T> comparator)
forEach(Iterable).iterable - The iterable of objects to be filteredcomparator - The comparator used to decide if 2 items are different or notpublic static <T,A> T selectMin(Object iterable, A argument)
forEach(Iterable).iterable - The iterable of objects to be filteredargument - An argument defined using the on(Class) methodpublic static <T,A> T selectMax(Object iterable, A argument)
forEach(Iterable).iterable - The iterable of objects to be filteredargument - An argument defined using the on(Class) methodpublic static <T> T aggregate(Object iterable, Aggregator<T> aggregator)
Aggregator.
Actually it handles also Maps, Arrays and Iterator by collecting their values.
Note that this method accepts an Object in order to be used in conjunction with the forEach(Iterable).iterable - The iterable of numbers to be summedaggregator - The function that defines how the objects in this iterable have to be aggregatedRuntimeException - if the iterable is not an Iterablepublic static <T,A> T aggregate(Object iterable, Aggregator<T> aggregator, A argument)
Aggregator.
Actually it handles also Maps, Arrays and Iterator by collecting their values.
Note that this method accepts an Object in order to be used in conjunction with the forEach(Iterable).iterable - The iterable of numbers to be summedaggregator - The function that defines how the objects in this iterable have to be aggregatedargument - An argument defined using the on(Class) methodRuntimeException - if the iterable is not an Iterablepublic static <T,A> T aggregateFrom(Iterable<T> iterable, Aggregator<A> aggregator)
iterable - The iterable of the objects to containing the property to be aggregated.aggregator - The function that defines how the objects in this iterable have to be aggregatedIllegalArgumentException - if the iterable is null or emptypublic static <T,A> T aggregateFrom(Iterable<T> iterable, Class<?> clazz, Aggregator<A> aggregator)
iterable - The iterable of the objects to containing the property to be aggregated.clazz - The class proxied by the returned objectaggregator - The function that defines how the objects in this iterable have to be aggregatedpublic static Number sum(Object iterable)
forEach(Iterable).iterable - The iterable of numbers to be summedIllegalArgumentException - if the iterable is not neither an Iterable nor a Numberpublic static <T> T sum(Object iterable, T argument)
forEach(Iterable).iterable - The iterable of items containing the property of which the values have to be summed.argument - An argument defined using the on(Class) methodIllegalArgumentException - if the iterable is not an Iterablepublic static <T> T sumFrom(Iterable<T> iterable)
int totalAge = sumFrom(persons).getAge();
The actual class of T is inferred from the class of the first iterable's item, but you can
specify a particular class by using the overloaded method.iterable - The iterable of the objects to containing the property to be summed.IllegalArgumentException - if the iterable is null or emptypublic static <T> T sumFrom(Iterable<T> iterable, Class<?> clazz)
int totalAge = sumFrom(persons, Person.class).getAge();
This overloaded version should be always used when it is not insured that the given iterable is null or empty.iterable - The iterable of the objects to containing the property to be summed.clazz - The class proxied by the returned objectpublic static Number avg(Object iterable)
forEach(Iterable).iterable - The iterable of numbers to be summedIllegalArgumentException - if the iterable is not neither an Iterable nor a Numberpublic static <T> T avg(Object iterable, T argument)
forEach(Iterable).iterable - The iterable of items containing the property for which the average of its the values has to be calculated.argument - An argument defined using the on(Class) methodIllegalArgumentException - if the iterable is not an Iterablepublic static <T> T avgFrom(Iterable<T> iterable)
int averageAge = avgFrom(persons).getAge();
The actual class of T is inferred from the class of the first iterable's item, but you can
specify a particular class by using the overloaded method.iterable - The iterable of the objects to containing the property for which the average has to be calculated.IllegalArgumentException - if the iterable is null or emptypublic static <T> T avgFrom(Iterable<T> iterable, Class<?> clazz)
int averageAge = avgFrom(persons, Person.class).getAge();
This overloaded version should be always used when it is not insured that the given iterable is null or empty.iterable - The iterable of the objects to containing the property for which the average has to be calculated.clazz - The class proxied by the returned objectpublic static <T> T min(Object iterable)
forEach(Iterable).iterable - The iterable of numbers to be summedIllegalArgumentException - if the iterable is not an Iterablepublic static <T> T min(Object iterable, T argument)
forEach(Iterable).iterable - The iterable of objects on which the minimum should be foundargument - An argument defined using the on(Class) methodIllegalArgumentException - if the iterable is not an Iterablepublic static <T> T minFrom(Iterable<T> iterable)
int minAge = maxFrom(persons).getAge();
The actual class of T is inferred from the class of the first iterable's item, but you can
specify a particular class by using the overloaded method.iterable - The iterable of objects on which the minimum should be foundIllegalArgumentException - if the iterable is null or emptypublic static <T> T minFrom(Iterable<T> iterable, Class<?> clazz)
int minAge = minFrom(persons).getAge();
This overloaded version should be always used when it is not insured that the given iterable is null or empty.iterable - The iterable of the objects containing the property of which the minimum should be found.clazz - The class proxied by the returned objectpublic static <T> T max(Object iterable)
forEach(Iterable).iterable - The iterable of objects on which the maximum should be foundIllegalArgumentException - if the iterable is not an Iterablepublic static <T> T max(Object iterable, T argument)
forEach(Iterable).iterable - The iterable of objects on which the maximum should be foundargument - An argument defined using the on(Class) methodIllegalArgumentException - if the iterable is not an Iterablepublic static <T> T maxFrom(Iterable<T> iterable)
int maxAge = maxFrom(persons).getAge();
The actual class of T is inferred from the class of the first iterable's item, but you can
specify a particular class by using the overloaded method.iterable - The iterable of objects on which the maximum should be foundIllegalArgumentException - if the iterable is null or emptypublic static <T> T maxFrom(Iterable<T> iterable, Class<?> clazz)
int maxAge = maxFrom(persons).getAge();
This overloaded version should be always used when it is not insured that the given iterable is null or empty.iterable - The iterable of the objects containing the property of which the maximum should be found.clazz - The class proxied by the returned objectpublic static <T> T joinFrom(Iterable<T> iterable)
String names = joinFrom(persons).getFirstName();
The actual class of T is inferred from the class of the first iterable's item, but you can
specify a particular class by using the overloaded method.iterable - The iterable of the objects to containing the property to be joined.IllegalArgumentException - if the iterable is null or emptypublic static <T> T joinFrom(Iterable<T> iterable, String separator)
String names = joinFrom(persons, " - ").getFirstName();
The actual class of T is inferred from the class of the first iterable's item, but you can
specify a particular class by using the overloaded method.iterable - The iterable of the objects to containing the property to be joined.separator - The String used to separe the Strings produced by this lambda functionIllegalArgumentException - if the iterable is null or emptypublic static <T> T joinFrom(Iterable<T> iterable, Class<?> clazz)
String names = joinFrom(persons, Person.class).getFirstName();
The actual class of T is inferred from the class of the first iterable's item, but you can
specify a particular class by using the overloaded method.
This overloaded version should be always used when it is not insured that the given iterable is null or empty.iterable - The iterable of the objects to containing the property to be joined.clazz - The class proxied by the returned objectpublic static <T> T joinFrom(Iterable<T> iterable, Class<?> clazz, String separator)
String names = joinFrom(persons, Person.class, " - ").getFirstName();
The actual class of T is inferred from the class of the first iterable's item, but you can
specify a particular class by using the overloaded method.
This overloaded version should be always used when it is not insured that the given iterable is null or empty.iterable - The iterable of the objects to containing the property to be joined.clazz - The class proxied by the returned objectseparator - The String used to separe the Strings produced by this lambda functionpublic static String join(Object iterable)
forEach(Iterable).iterable - The iterable containing the objects to be joinedpublic static String join(Object iterable, String separator)
forEach(Iterable).iterable - The iterable containing the objects to be joinedseparator - The String used to separe the item's String representationpublic static <F,T> List<T> convert(Object iterable, Converter<F,T> converter)
Converter.
Actually it handles also Maps, Arrays and Iterator by collecting their values.
Note that this method accepts an Object in order to be used in conjunction with the forEach(Iterable).iterable - The iterable containing the objects to be convertedconverter - The converter that specifies how each object in the iterable must be convertedConverterpublic static <F,T> Iterator<T> convertIterator(Object iterable, Converter<F,T> converter)
Converter.
Actually it handles also Maps, Arrays and Iterator by collecting their values.
Note that this method accepts an Object in order to be used in conjunction with the forEach(Iterable).iterable - The iterable containing the objects to be convertedconverter - The converter that specifies how each object in the iterable must be convertedConverterpublic static <K,F,T> Map<K,T> convertMap(Map<K,F> map, Converter<F,T> converter)
Converter.map - The map containing the values to be convertedconverter - The converter that specifies how each map's value must be convertedpublic static <K,F,T> Map<K,T> convertMap(Map<K,F> map, T argument)
map - The map containing the values to be convertedargument - An argument defined using the on(Class) methodpublic static <F,T> List<T> extract(Object iterable, T argument)
forEach(Iterable).iterable - The iterable containing the objects to be convertedargument - An argument defined using the on(Class) methodpublic static <F,T> Iterator<T> extractIterator(Object iterable, T argument)
extract(Object, Object) this one doesn't build a new collection, and the
extraction is done only when someone iterates over the returned iterator.
Note that this method accepts an Object in order to be used in conjunction with the forEach(Iterable).iterable - The iterable containing the objects to be convertedargument - An argument defined using the on(Class) methodpublic static List<String> extractString(Object iterable)
forEach(Iterable).iterable - The iterable containing the objects to be converted in stringspublic static <F,T> List<T> extractProperty(Object iterable, String propertyName)
forEach(Iterable).iterable - The iterable containing the objects to be convertedpropertyName - The name of the item's property on which the item must have no duplicated valuepublic static <F,T> Map<T,F> map(Object iterable, Converter<F,T> converter)
Converter.
Actually it handles also Maps, Arrays and Iterator by collecting their values.
Note that this method accepts an Object in order to be used in conjunction with the forEach(Iterable).iterable - The iterable containing the objects to be mappedconverter - The converter that specifies the key on which each object should be mappedpublic static <F,T> Map<T,F> index(Object iterable, T argument)
forEach(Iterable).iterable - The iterable containing the objects to be indexedargument - An argument defined using the on(Class) methodpublic static <T> List<T> project(Object iterable, Class<T> targetClass, Object... arguments)
forEach(Iterable).iterable - The iterable containing the objects to be projectedtargetClass - The class in which the objects in the given iterable must be convertedarguments - The arguments of the objects to be converted that will be used to create the objects of the target classpublic static <F> List<Map<String,Object>> project(Object iterable, Converter<F,Map.Entry<String,Object>>... projectors)
forEach(Iterable).iterable - The iterable containing the objects to be projectedprojectors - The converters that define how each object should be projectedpublic static <F> Converter<F,Map.Entry<String,Object>> as(Object argument)
Argument.getInkvokedPropertyName()argument - An argument defined using the on(Class) methodproject(Object, Converter[]) methodpublic static <F> Converter<F,Map.Entry<String,Object>> as(String alias, Object argument)
alias - The key on which the argument value is pairedargument - An argument defined using the on(Class) methodproject(Object, Converter[]) methodpublic static <T> HasArgumentWithValue<T,Boolean> having(Boolean argument)
argument - The boolean argument defined using the on(Class) method that has to be matchedpublic static <T,A> HasArgumentWithValue<T,A> having(A argument, org.hamcrest.Matcher<?> matcher)
argument - The argument defined using the on(Class) method that has to be matchedmatcher - The matcher against which the value of the given argument has to be comparedpublic static <T> ArgumentGroupCondition<T> by(T argument)
argument - The argument defined using the on(Class) method on which the items have to be groupedGroups.group(Iterable, ch.lambdaj.group.GroupCondition[]) methodpublic static <T> Group<T> group(Iterable<T> iterable, Collection<? extends GroupCondition<?>> conditions)
iterable - The items to be groupedconditions - The conditions that define how the items have to be groupedpublic static <T> Group<T> group(Iterable<T> iterable, String... groupers)
iterable - The items to be groupedgroupers - The names of the properties on which the items have to be groupedpublic static <T> Group<T> group(Iterable<T> iterable, GroupCondition<?>... conditions)
iterable - The items to be groupedconditions - The conditions that define how the items have to be groupedpublic static <T> T of(T closed)
closed - The object that has to be bound to the active closurepublic static <T> T of(Class<T> closedClass)
closedClass - The type of the free variable to be bound to the active closurepublic static <T> T of(T closed,
Class<T> closedClass)
closed - The object that has to be bound to the active closureclosedClass - The actual class of the proxied objectpublic static <T> T var(Class<T> clazz)
clazz - The Class of the new argumentpublic static Closure closure()
public static <A> Closure1<A> closure(Class<A> type1)
type1 - The type of the free parameter of the newly created closurepublic static <A,B> Closure2<A,B> closure(Class<A> type1, Class<B> type2)
type1 - The type of the first free variable of the newly created closuretype2 - The type of the second free variable of the newly created closurepublic static <A,B,C> Closure3<A,B,C> closure(Class<A> type1, Class<B> type2, Class<C> type3)
type1 - The type of the first free variable of the newly created closuretype2 - The type of the second free variable of the newly created closuretype3 - The type of the third free variable of the newly created closurepublic static <A,B,C,D> Closure4<A,B,C,D> closure(Class<A> type1, Class<B> type2, Class<C> type3, Class<D> type4)
type1 - The type of the first free variable of the newly created closuretype2 - The type of the second free variable of the newly created closuretype3 - The type of the third free variable of the newly created closuretype4 - The type of the fourth free variable of the newly created closurepublic static <T> ClosureResult<T> delayedClosure(DelayedClosure<T> delayedClosure)
delayedClosure - The closure defined through the DelayedClosure syntaxCopyright © 2012. All Rights Reserved.