public class ValueResolver<T> extends java.lang.Object implements DeferredSupplier<T>
Tasks or a DeferredSupplier then get its contents
deep(boolean) is requested, it applies resolution to contents
Fluent-style API exposes a number of other options.
| Modifier and Type | Class and Description |
|---|---|
static class |
ValueResolver.ResolverBuilderPretype |
| Modifier and Type | Field and Description |
|---|---|
static Duration |
PRETTY_QUICK_WAIT
Period to wait if we're expected to return quickly
but we want to be a bit more generous for things to finish,
without letting a caller get annoyed.
|
static Duration |
REAL_QUICK_PERIOD
Period to wait when we have to poll but want to give the illusion of no wait.
|
static Duration |
REAL_QUICK_WAIT
Period to wait if we're expected to return real quick
but we want fast things to have time to finish.
|
| Modifier and Type | Method and Description |
|---|---|
ValueResolver<T> |
clone()
returns a copy of this resolver which can be queried, even if the original (single-use instance) has already been copied
|
ValueResolver<T> |
context(Entity entity)
as
context(ExecutionContext) for use from an entity |
ValueResolver<T> |
context(ExecutionContext exec)
execution context to use when resolving; required if resolving unsubmitted tasks or running with a time limit
|
ValueResolver<T> |
deep(boolean forceDeep)
causes nested structures (maps, lists) to be descended and nested unresolved values resolved
|
ValueResolver<T> |
defaultValue(T defaultValue)
sets a default value which will be returned on a call to
get() if the task does not complete
or completes with an error |
ValueResolver<T> |
description(java.lang.String description)
sets a message which will be displayed in status reports while it waits (e.g.
|
ValueResolver<T> |
embedResolutionInTask(java.lang.Boolean embedResolutionInTask)
if true, forces execution of a deferred supplier to be run in a task;
if false, it prevents it (meaning time limits may not be applied);
if null, the default, it runs in a task if a time limit is applied.
|
T |
get() |
Maybe<T> |
getDefault() |
Maybe<T> |
getMaybe() |
ValueResolver<T> |
noDefaultValue()
indicates that no default value should be returned on a call to
get(), and instead it should throw
(this is the default; this method is provided to undo a call to defaultValue(Object)) |
ValueResolver<T> |
swallowExceptions()
indicates that exceptions in resolution should not be thrown on a call to
getMaybe(),
but rather used as part of the Maybe.get() if it's absent,
and swallowed altogether on a call to get() in the presence of a defaultValue(Object) |
ValueResolver<T> |
timeout(Duration timeout)
sets a time limit on executions
|
java.lang.String |
toString() |
ValueResolver<T> |
transientTask(boolean isTransientTask)
whether the task should be marked as transient; defaults true
|
public static Duration REAL_QUICK_WAIT
Timings are always somewhat arbitrary but this at least allows some intention to be captured in code rather than arbitrary values.
public static Duration PRETTY_QUICK_WAIT
See REAL_QUICK_WAIT.
public static Duration REAL_QUICK_PERIOD
Repeater.DEFAULT_REAL_QUICK_PERIODpublic ValueResolver<T> clone()
clone in class java.lang.Objectpublic ValueResolver<T> context(ExecutionContext exec)
public ValueResolver<T> context(Entity entity)
context(ExecutionContext) for use from an entitypublic ValueResolver<T> description(java.lang.String description)
public ValueResolver<T> defaultValue(T defaultValue)
get() if the task does not complete
or completes with an error
note that getMaybe() returns an absent object even in the presence of
a default, so that any error can still be accessed
public ValueResolver<T> noDefaultValue()
get(), and instead it should throw
(this is the default; this method is provided to undo a call to defaultValue(Object))public ValueResolver<T> swallowExceptions()
getMaybe(),
but rather used as part of the Maybe.get() if it's absent,
and swallowed altogether on a call to get() in the presence of a defaultValue(Object)public ValueResolver<T> transientTask(boolean isTransientTask)
public ValueResolver<T> deep(boolean forceDeep)
public ValueResolver<T> embedResolutionInTask(java.lang.Boolean embedResolutionInTask)
running inside a task is required for some DeferredSupplier
instances which look up a task ExecutionContext.
public ValueResolver<T> timeout(Duration timeout)
used for Task and DeferredSupplier instances.
may require an execution context at runtime.
public T get()
get in interface DeferredSupplier<T>get in interface com.google.common.base.Supplier<T>public java.lang.String toString()
toString in class java.lang.Object