DynamicLocalizer

Special localizer class that allows to pick an arbitrary PolyglotReferenceDateTimeLocalizer based on the current reference time.

On localization, it goes through each one of thresholds, stopping at the first one whose reference is in Case.Threshold.range, and returning its value. If the reference is in none of the thresholds' ranges, default is selected instead.

Note that it is not recommended to provide thresholds that overlap. However, the class will not stop you from doing that and should work correctly regardless.

The next tick is selected with the minimum between the selected case and all thresholds that come before it.

Constructors

Link copied to clipboard

Types

Link copied to clipboard
sealed interface Case<T>

Properties

Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
open override fun localize(value: T, reference: Zoned<Instant>): TickingValue<String>
Link copied to clipboard
fun <T, R> PolyglotReferenceValueLocalizer<T, R>.localizeAsFlow(value: T, clock: Flow<ClockWrapper> = SYSTEM_CLOCK, timeZone: Flow<TimeZone> = SYSTEM_TIMEZONE, maxTick: Duration? = null): Flow<R>

Localizes value by using the given clock's Clock.now and timeZone flows as a reference point and returns a Flow that emits updated values based on the underlying TickingValue.nextTick. This function assumes that each Clock emitted by the clock flow moves forward linearly.

Link copied to clipboard
fun <T, R> PolyglotReferenceValueLocalizer<T, R>.localizeNow(value: T, clock: Clock = Clock.System, timeZone: TimeZone = TimeZone.currentSystemDefault()): TickingValue<R>

Localizes value by using the given clock's Clock.now and timeZone as a reference point, rather than passing the reference explicitly.

Link copied to clipboard

Returns a new PolyglotReferenceValueLocalizer that localizes the received value using this localizer, calls map, and returns whatever TickingValue the mapping function returns.

Link copied to clipboard