type of used context, e.g., MyContext
.
type of used context, e.g., MyContext
.
case class MyContext( identity: User )
Context-aware Reads
Context-aware Reads
Context-aware Writes
Context-aware Writes
markup trait marking classes for Reads/Writes materialization
markup trait marking classes for Reads/Writes materialization
encapsulates a Context with the processed instance
encapsulates a Context with the processed instance
Note: There is Any because we are unable to parametrize WriteContext[ T ] and use it
within @when[ T ]. Scala would require manual providing [ T ] also when we do not need it.
The solution would be to generate the type via macros, but annotation macro cannot be used
within traits and it cannot be pulled out because it uses path-dependent Context type. In
consequence, this falls back to Any and getter model[ T ]
, because of lack of support in macros.
encapsulates a Context with the processed instance
encapsulates a Context with the processed instance
Note: There is Any because we are unable to parametrize WriteContext[ T ] and use it
within @when[ T ]. Scala would require manual providing [ T ] also when we do not need it.
The solution would be to generate the type via macros, but annotation macro cannot be used
within traits and it cannot be pulled out because it uses path-dependent Context type. In
consequence, this falls back to Any and getter model[ T ]
, because of lack of support in macros.
set of helper functions used within ContextualReads macro to simplify the implementation
set of helper functions used within ContextualReads macro to simplify the implementation
macro materializer of context-aware Reads
macro materializer of context-aware Reads
macro materializer of context-aware Writes
macro materializer of context-aware Writes
resolver of context-aware reads into regular reads.
resolver of context-aware reads into regular reads. Note: these resolved reads are valid only within given context!
implicit helper to unwrap write context into regular context
implicit helper to unwrap write context into regular context
resolver of context-aware writes into regular writes.
resolver of context-aware writes into regular writes. Note: these resolved writes are valid only within given context!
(Since version ) see corresponding Javadoc for more information.
The library considers context-aware JSON processing. It means that for every data processing it accepts current execution context containing, e.g., user's identity, application state, user's privileges, etc. This enables us to use these contextual data within conditions and transformations to provide/read only data matching these conditions.
Instances of
ContextualJson
implements the protocol and provides Reads and Writes materializers, including context type and implicit conversions. Everywhere we want to use the protocol we have to import everything from our protocol instance.Example
Define the context
Define the protocol
And then we import it everywhere we use the protocol