|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.sf.staccatocommons.lang.thunk.Thunks
public class Thunks
Class factory methods for some common Thunks
| Method Summary | ||
|---|---|---|
static
|
constant(A value)
Returns a thunk that returns always the given value |
|
static net.sf.staccatocommons.defs.Thunk<Date> |
currentDate()
Returns a Thunk that provides the current date |
|
static
|
fail(String message,
Object... args)
Answers a Thunk that, when evaluated, throws an exception with the given
formatted message as Ensure.fail(String, Object...) |
|
static
|
from(Callable<A> callable)
Returns a thunk whose value is retrieved sending Callable.call() to
the given Callable |
|
static net.sf.staccatocommons.defs.Thunk<Void> |
from(Runnable runnable)
Returns a cell that provides not actual value, but a side effect instead, by sending Runnable.run() to the given runnable |
|
static
|
null_()
Returns a constant Thunk that always provides null |
|
static
|
undefined()
Returns a thunk that when evaluated throws a RuntimeException. |
|
static
|
value()
Returns a Function that evaluates its Thunk argument |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static <A> net.sf.staccatocommons.defs.Thunk<A> constant(A value)
A - value - the value the constant thunk will return as when invoking
Thunk.value()
@Constant public static <A> net.sf.staccatocommons.defs.Thunk<A> null_()
Thunk that always provides null
A -
@Constant public static net.sf.staccatocommons.defs.Thunk<Date> currentDate()
Thunk that provides the current date
new Date()
public static <A> net.sf.staccatocommons.defs.Thunk<A> from(@NonNull
Callable<A> callable)
Callable.call() to
the given Callable
A - callable -
Thunk that wraps the given callable@Constant public static <A> net.sf.staccatocommons.defs.Thunk<A> undefined()
RuntimeException. This
Thunk is said to have an undefined element.
A -
Constant undefined thunk
public static <A> net.sf.staccatocommons.defs.Thunk<A> fail(@NonNull
String message,
Object... args)
Thunk that, when evaluated, throws an exception with the given
formatted message as Ensure.fail(String, Object...)
message - the messageargs - the message arguments
Thunk that fails with the given message
public static net.sf.staccatocommons.defs.Thunk<Void> from(@NonNull
Runnable runnable)
Runnable.run() to the given runnable
runnable -
Thunk that wraps the given Runnable@Constant public static <A> net.sf.staccatocommons.defs.function.Function<net.sf.staccatocommons.defs.Thunk<A>,A> value()
Function that evaluates its Thunk argument
A -
Function
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||