public final class Functions extends Object
Modifier and Type | Method and Description |
---|---|
static <T> Comparator<T> |
comparator(Function<T,Comparable> comparableFunction)
Creates a comparator that takes a function as input.
|
static <A,B,C> Function2<Function<? super B,C>,Function<A,B>,Function<A,C>> |
compose() |
static <FROM,MIDDLE,TO> |
compose(Function<? super MIDDLE,TO> outer,
Function<FROM,MIDDLE> inner)
compose(F1(M,T),F2(F,M)) = F1(F2(F)) -> T
|
static <T> Function<T,Integer> |
count(Specification<T> specification)
Count the number of items in an iterable that matches a given specification.
|
static <T> Function<T,T> |
filteredMap(Specification<T> specification,
Function<T,T> function)
Only apply given function on objects that satisfies the given specification.
|
static <FROM,TO> Function<FROM,TO> |
fromMap(Map<FROM,TO> map) |
static <TO,FROM extends TO> |
identity() |
static <T> Function<T,Integer> |
indexOf(Specification<T> specification)
Find out the index of an item matching a given specification in an iterable.
|
static <T> int |
indexOf(T item,
Iterable<T> iterable)
Find out the index of an item in an iterable.
|
static Function<Number,Integer> |
intSum() |
static Function<Number,Long> |
longSum() |
static <T> Function<T,T> |
withDefault(T defaultValue) |
public static <A,B,C> Function2<Function<? super B,C>,Function<A,B>,Function<A,C>> compose()
public static <FROM,MIDDLE,TO> Function<FROM,TO> compose(Function<? super MIDDLE,TO> outer, Function<FROM,MIDDLE> inner)
outer
- The outer/encapsulating functioninner
- The inner/encapsulated functionpublic static <TO,FROM extends TO> Function<FROM,TO> identity()
public static <T> Function<T,T> withDefault(T defaultValue)
public static <T> Function<T,Integer> count(Specification<T> specification)
T
- The type of the items.specification
- The items that adhere to the Specification is counted.public static <T> Function<T,Integer> indexOf(Specification<T> specification)
T
- The type of the items.specification
- The Specification that specifies what to look for.public static <T> int indexOf(T item, Iterable<T> iterable)
T
- The type of the items.item
- The item to look for.iterable
- The Iterable to search.public static <T> Function<T,T> filteredMap(Specification<T> specification, Function<T,T> function)
T
- The type of the items.specification
- A Specification that specifies what should be included in the filtered result.function
- The function to be applied to items that fulfills the Specificationpublic static <T> Comparator<T> comparator(Function<T,Comparable> comparableFunction)
T
- The generic type to be used.comparableFunction
- The Function that the Comparator will delegate to.