Class RenderContext
java.lang.Object
io.mindspice.simplypages.core.RenderContext
Mutable per-render value container for
SlotKey lookups.
Lifecycle: create per request/render flow, populate slot values, render components, then discard. This type is intentionally mutable to support incremental population and optional compile-on-first-hit slot caching.
Mutability/thread-safety: mutable and not thread-safe. Use per request by default. Context
reuse is valid only when access is confined (no concurrent mutation), especially when using
RenderContext.RenderPolicy.COMPILE_ON_FIRST_HIT.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classMutable builder forRenderContext.static enumControls whether slot render output may be cached as compiled HTML entries. -
Method Summary
Modifier and TypeMethodDescriptionbuilder()Returns a builder for explicit context construction.clear()Removes all entries from this context.static RenderContextempty()Returns an empty context usingRenderContext.RenderPolicy.NEVER_COMPILE.<T> Optional<T> Resolves the value forkey.getCompiled(SlotKey<?> key) Returns compiled HTML forkeywhen a compiled entry exists.Returns an immutable snapshot of stored entries.Returns current render policy.booleanisCompiled(SlotKey<?> key) Returns whetherkeycurrently maps to a compiled entry.static <T> RenderContextCreates a context with a single raw slot value and default policy.static RenderContextCreates a context from raw slot values with default policy.<T> RenderContextStores a live value forkey;nullremoves the entry.putCompiled(SlotKey<?> key, String html) Stores pre-rendered trusted HTML forkey;nullremoves the entry.Removes any entry forkey.withPolicy(RenderContext.RenderPolicy policy) Sets render policy for subsequent template slot handling.
-
Method Details
-
empty
Returns an empty context usingRenderContext.RenderPolicy.NEVER_COMPILE. -
builder
Returns a builder for explicit context construction. -
of
Creates a context from raw slot values with default policy.nullvalues remove existing entries. -
of
Creates a context with a single raw slot value and default policy.nullvalues produce an empty context for the given key. -
get
-
put
Stores a live value forkey;nullremoves the entry. -
putCompiled
Stores pre-rendered trusted HTML forkey;nullremoves the entry. -
remove
Removes any entry forkey. -
clear
Removes all entries from this context. -
withPolicy
Sets render policy for subsequent template slot handling.- Throws:
NullPointerException- whenpolicyis null
-
getPolicy
Returns current render policy. -
isCompiled
Returns whetherkeycurrently maps to a compiled entry. -
getCompiled
-
getEntries
-