public abstract class SoyAbstractCachingValueProvider extends Object implements SoyValueProvider
SoyAbstractCachingValueProvider is thread-safe, but in a race condition, may compute its value twice.
Important: Do not use outside of Soy code (treat as superpackage-private).
| Modifier and Type | Class and Description |
|---|---|
static class |
SoyAbstractCachingValueProvider.ValueAssertion
A mechanism to plug in assertions on the computed value that will be run the first time the
value is
computed. |
| Constructor and Description |
|---|
SoyAbstractCachingValueProvider() |
| Modifier and Type | Method and Description |
|---|---|
void |
addValueAssertion(SoyAbstractCachingValueProvider.ValueAssertion assertion)
Registers a
SoyAbstractCachingValueProvider.ValueAssertion callback with this caching provider. |
protected abstract SoyValue |
compute()
Implemented by subclasses to do the heavy-lifting for resolving.
|
int |
hashCode() |
boolean |
isComputed()
Returns
true if the caching provider has already been calculated. |
RenderResult |
renderAndResolve(LoggingAdvisingAppendable appendable,
boolean isLast)
Renders this value to the given
LoggingAdvisingAppendable,
possibly partially. |
SoyValue |
resolve()
Usually, this method is a no-op that simply returns this object.
|
clone, equals, finalize, getClass, notify, notifyAll, toString, wait, wait, waitstatuspublic final SoyValue resolve()
SoyValueProviderresolve in interface SoyValueProviderpublic RenderResult renderAndResolve(LoggingAdvisingAppendable appendable, boolean isLast) throws IOException
SoyValueProviderLoggingAdvisingAppendable,
possibly partially.
This should render the exact same content as resolve().render(Appendable) but may
optionally detach part of the way through rendering. Note, this means that this method is
stateful and if it returns something besides RenderResult.done() then the next
call to this method will resume rendering from the previous point.
renderAndResolve in interface SoyValueProviderappendable - The appendable to render to.isLast - True if this is definitely the last time this value will be rendered.
Used as a hint to implementations to not optimize for later calls (for example, by storing
render results in a buffer for faster re-renders). The value of this parameter should not
affect behavior of this method, only performance.RenderResult that describes whether or not rendering completed. If the
returned result is not done, then to complete rendering you
must call this method again.IOException - If the appendable throws an IOExceptionpublic final boolean isComputed()
true if the caching provider has already been calculated.public void addValueAssertion(SoyAbstractCachingValueProvider.ValueAssertion assertion)
SoyAbstractCachingValueProvider.ValueAssertion callback with this caching provider.protected abstract SoyValue compute()