@ForUseOnly public interface JsonGenerationContext
GenerationContext
for json.
The JsonGenerationContext is used to hold and distribute all information regarding the rendering of a JSON document.
CAUTION:
This class is still in development and may change drastically without any further notice.Modifier and Type | Interface and Description |
---|---|
static interface |
JsonGenerationContext.JsonLogger
Logger interface used in the
JsonGenerationContext . |
Modifier and Type | Method and Description |
---|---|
<O> Optional<O> |
getAttribute(String name)
Lookup an attribute with the given
name in the current stack. |
Language |
getLanguage()
Returns the current
Language of this generation context. |
JsonGenerationContext.JsonLogger |
getLogger()
Returns the
JsonGenerationContext.JsonLogger of the current JsonGenerationContext . |
JsonSettings |
getSettings()
Returns the current
json settings of this generation context. |
<T> JsonElement<?> |
handle(T object)
Entry point for the transformation of an object to a
JsonElement . |
boolean |
isRelease()
Indicates whether this
context is based on a release version. |
<O> void |
setAttribute(String name,
O value)
Sets the given value in the this
context . |
@NotNull <T> JsonElement<?> handle(@Nullable T object)
JsonElement
.
If eligible, the transformation will also include dependent objects in a hierarchical manner and potentially include
form data
, meta data
, bodies
, sections
and template
information
of FirstSpirit objects.T
- the type of the given objectobject
- the object to transform to jsonJsonElement
@NotNull JsonGenerationContext.JsonLogger getLogger()
JsonGenerationContext.JsonLogger
of the current JsonGenerationContext
.JsonGenerationContext.JsonLogger
JsonGenerationContext.JsonLogger
<O> void setAttribute(@NotNull String name, @Nullable O value)
context
. The values will be stored in a stack which
will automatically get pushed/popped when rendering hierarchical objects. The given name
will be used as an unique identifier
for the current attribute stack
. Using the same name on the same stack will result in overwriting the value in the current
context
.O
- the type of the given valuename
- the name of the value, must be uniquevalue
- the value to set in this contextgetAttribute(String)
@NotNull <O> Optional<O> getAttribute(@NotNull String name)
name
in the current stack. If the value is not present in the current stack, this method will
try to find it in all stacks below the current one and return the first occurrence. If no occurrence is found, an empty Optional
will be returned.O
- the type of the value to lookupname
- the name of the attribute to lookupOptional
setAttribute(String, Object)
boolean isRelease()
context
is based on a release version.true
this context is based on a release versionGenerationContext.isRelease()
@Nullable Language getLanguage()
Language
of this generation context.Language
GenerationContext.getLanguage()
@NotNull JsonSettings getSettings()
json settings
of this generation context.json settings
oGenerationContext.getJson()
,
JsonSettings
Copyright © 2021 e-Spirit AG. All Rights Reserved. Build 5.2.210210