|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.sf.staccatocommons.lang.function.Functions
public class Functions
Class factory methods for some common Functions
| Method Summary | ||
|---|---|---|
static
|
constant(B value)
Returns a function that takes one argument, and regardless of it, returns a given value. |
|
static
|
constant(net.sf.staccatocommons.defs.Thunk<B> thunk)
Returns a function that takes one argument, and regadless of it, returns the given thunk's value. |
|
static
|
from(net.sf.staccatocommons.defs.Applicable<? super A,? extends B> applicable)
Converts the given Applicable into a Function by casting
it, is possible, or creating a new function that delegates its apply method
to it. |
|
static
|
from(net.sf.staccatocommons.defs.Applicable2<? super A,? super B,? extends C> applicable)
Converts the given Applicable2 into a Function2 by casting
it, is possible, or creating a new function that delegates its apply method
to it. |
|
static
|
identity()
Returns the identity function, that is, a Function that takes an
argument and returns it. |
|
static
|
impure(net.sf.staccatocommons.defs.Executable<? super A> block)
Answers an impure - with side effect - function that executes the given block and answers its argument |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
@NonNull
public static <A,B> net.sf.staccatocommons.defs.function.Function<A,B> from(@NonNull
net.sf.staccatocommons.defs.Applicable<? super A,? extends B> applicable)
Applicable into a Function by casting
it, is possible, or creating a new function that delegates its apply method
to it.
A - B - applicable - the Applicable to convert
Applicable, if it is
not already a Function, or the given
applicable casted to Function, otherwise
@NonNull
public static <A,B,C> net.sf.staccatocommons.defs.function.Function2<A,B,C> from(@NonNull
net.sf.staccatocommons.defs.Applicable2<? super A,? super B,? extends C> applicable)
Applicable2 into a Function2 by casting
it, is possible, or creating a new function that delegates its apply method
to it.
A - B - C - applicable - the Applicable to convert
Applicable2, if it is
not already a Function2, or the given
applicable casted to Function2, otherwise@Constant public static <A> net.sf.staccatocommons.defs.function.Function<A,A> identity()
Function that takes an
argument and returns it. This functions grants to be Transparent
A -
@NonNull public static <A,B> net.sf.staccatocommons.defs.function.Function<A,B> constant(B value)
Transparent and
Constant
A - B - value - the value the function will return when applied
@NonNull
public static <A,B> net.sf.staccatocommons.defs.function.Function<A,B> constant(@NonNull
net.sf.staccatocommons.defs.Thunk<B> thunk)
This function grants to be Transparent and Constant only as
long as the given thunk is transparent too. As a consequence,
passing a non-transparent Thunk may be effective, but
counterintuitive, as the resulting function would be impure and not
constant at all.
A - B - thunk -
public static <A> net.sf.staccatocommons.defs.function.Function<A,A> impure(@NonNull
net.sf.staccatocommons.defs.Executable<? super A> block)
A - block - the block to wrap
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||