Record Class SlotKey<T>
java.lang.Object
java.lang.Record
io.mindspice.simplypages.core.SlotKey<T>
- Type Parameters:
T- slot value type- Record Components:
name- non-null literal slot namedefaultProvider- nullable default function; not evaluated during construction
Typed identifier for values stored in a
RenderContext.
Names must be non-null and are preserved literally, including empty and blank strings. No trimming, case folding, or Unicode normalization is applied.
Equality and hash code use only name(), not the generic type or default provider.
Separately created keys with the same name address the same slot; use a consistent type for
each name.
Usage boundary: keys are consumed by slot-aware rendering in either direct component renders
or compiled Template renders.
Mutability/thread-safety: immutable and thread-safe. Thread-safety of default evaluation
depends on the provided defaultProvider() implementation.
-
Constructor Summary
ConstructorsConstructorDescriptionSlotKey(String name, Function<RenderContext, T> defaultProvider) Creates a key without evaluating its default provider. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of thedefaultProviderrecord component.booleanIndicates whether some other object is "equal to" this one.getDefault(RenderContext context) Resolves the default value for this key.inthashCode()Returns a hash code value for this object.name()Returns the value of thenamerecord component.static <T> SlotKey<T> Creates a key with no default provider.static <T> SlotKey<T> of(String name, Function<RenderContext, T> defaultProvider) Creates a key with a computed default.static <T> SlotKey<T> Creates a key with a constant default value.toString()Returns a string representation of this record class.
-
Constructor Details
-
SlotKey
Creates a key without evaluating its default provider.- Parameters:
name- non-null literal slot namedefaultProvider- default function, ornullfor no default- Throws:
NullPointerException- ifnameis null
-
-
Method Details
-
of
Creates a key with no default provider.- Parameters:
name- non-null literal slot name- Throws:
NullPointerException- ifnameis null
-
of
Creates a key with a constant default value.- Parameters:
name- non-null literal slot namedefaultValue- default used when slot has no explicit entry- Throws:
NullPointerException- ifnameis null
-
of
Creates a key with a computed default.- Parameters:
name- non-null literal slot namedefaultProvider- default function invoked when slot has no explicit entry, ornullfor no default; not evaluated during construction- Throws:
NullPointerException- ifnameis null
-
getDefault
Resolves the default value for this key.- Parameters:
context- render context passed todefaultProvider()- Returns:
- default value, or
nullwhen no provider exists
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
hashCode
-
toString
-
name
-
defaultProvider
Returns the value of thedefaultProviderrecord component.- Returns:
- the value of the
defaultProviderrecord component
-