rd-framework / com.jetbrains.rd.framework / RdContext

RdContext

abstract class RdContext<T : Any>

Describes a context and provides access to value associated with this context. The associated value is thread-local and synchronized between send/advise pairs on IWire. The associated value will be the same in handler method in IWire.advise as it was in IWire.send. Instances of this class with the same key will share the associated value. Best practice is to declare contexts in toplevel entities in protocol model using Toplevel.context. Manual declaration is also possible.

Parameters

key - textual name of this context. This is used to match this with protocol counterparts

heavy - Whether or not this context is heavy. A heavy context maintains a value set and interns values. A light context sends values as-is and does not maintain a value set.

serializer - Serializer to be used with this context.

See Also

com.jetbrains.rd.generator.nova.Toplevel.context

Types

Companion

companion object Companion : ISerializer<RdContext<*>>

Constructors

<init>

RdContext(key: String, heavy: Boolean, serializer: IMarshaller<T>)

Describes a context and provides access to value associated with this context. The associated value is thread-local and synchronized between send/advise pairs on IWire. The associated value will be the same in handler method in IWire.advise as it was in IWire.send. Instances of this class with the same key will share the associated value. Best practice is to declare contexts in toplevel entities in protocol model using Toplevel.context. Manual declaration is also possible.

Properties

heavy

val heavy: Boolean

Whether or not this context is heavy. A heavy context maintains a value set and interns values. A light context sends values as-is and does not maintain a value set.

key

val key: String

textual name of this context. This is used to match this with protocol counterparts

serializer

val serializer: IMarshaller<T>

Serializer to be used with this context.

value

var value: T?

The current (thread-local) value for this context

valueForPerContextEntity

open var valueForPerContextEntity: T?

Value which is used as a key inside per-context entities like RdPerContextMap

Functions

equals

open fun equals(other: Any?): Boolean

hashCode

open fun hashCode(): Int

Companion Object Functions

marshallerFor

fun marshallerFor(context: RdContext<*>): IMarshaller<RdContext<*>>

read

fun read(ctx: SerializationCtx, buffer: AbstractBuffer): RdContext<*>

write

fun write(ctx: SerializationCtx, buffer: AbstractBuffer, value: RdContext<*>): Unit

Extension Functions

deepClonePolymorphic

fun <T> T.deepClonePolymorphic(): T