com.im.commons 5.9

com.im.commons
Class Functional

java.lang.Object
  extended by com.im.commons.Functional

public final class Functional
extends Object


Method Summary
static
<F,T> Function<F,T>
constant(T value)
          Creates a constant function that returns value for any input.
static
<A,B> A
foldlNull(Function<Pair<A,B>,A> f, A z, Iterable<B> xs)
          Version of foldl as it is known in functional programming word handling the null values.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

foldlNull

public static <A,B> A foldlNull(Function<Pair<A,B>,A> f,
                                A z,
                                Iterable<B> xs)
Version of foldl as it is known in functional programming word handling the null values.

Applied to a binary operator, a starting value (typically the left-identity of the operator), and a list, reduces the list using the binary operator, from left to right:

Parameters:
f - reducing operator
z - starting value
xs - the list to be reduced
Returns:
reduced result

constant

public static <F,T> Function<F,T> constant(T value)
Creates a constant function that returns value for any input. I.e. it ignore its input parameter.

This function is similar to the Functions.constant(E) from Guava library but is generic in its input parameter which fits better in some scenarios.

Parameters:
value - the constant value for the function to return
Returns:
a constant function that always returns value

com.im.commons 5.9