Interface JsonGenerationContext
@NonExtendable
@Experimental
public interface JsonGenerationContext
Interface representing a specialized version of the
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.- Since:
- 5.2.191206
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
Logger interface used in theJsonGenerationContext
. -
Method Summary
Modifier and TypeMethodDescription<O> @NotNull Optional<O>
getAttribute
(@NotNull String name) Lookup an attribute with the givenname
in the current stack.@Nullable Language
Returns the currentLanguage
of this generation context.@NotNull JsonGenerationContext.JsonLogger
Returns theJsonGenerationContext.JsonLogger
of the currentJsonGenerationContext
.@NotNull JsonSettings
Returns the currentjson settings
of this generation context.<T> @NotNull JsonElement<?>
handle
(T object) Entry point for the transformation of an object to aJsonElement
.boolean
Indicates whether thiscontext
is based on a release version.<O> void
setAttribute
(@NotNull String name, O value) Sets the given value in the thiscontext
.
-
Method Details
-
handle
Entry point for the transformation of an object to aJsonElement
. If eligible, the transformation will also include dependent objects in a hierarchical manner and potentially includeform data
,meta data
,bodies
,sections
andtemplate
information of FirstSpirit objects.- Type Parameters:
T
- the type of the given object- Parameters:
object
- the object to transform to json- Returns:
- the transformed
JsonElement
- Since:
- 5.2.191206
-
getLogger
Returns theJsonGenerationContext.JsonLogger
of the currentJsonGenerationContext
.- Returns:
- the current
JsonGenerationContext.JsonLogger
- Since:
- 5.2.191206
- See Also:
-
setAttribute
Sets the given value in the thiscontext
. The values will be stored in a stack which will automatically get pushed/popped when rendering hierarchical objects. The givenname
will be used as an unique identifier for the currentattribute stack
. Using the same name on the same stack will result in overwriting the value in the currentcontext
.- Type Parameters:
O
- the type of the given value- Parameters:
name
- the name of the value, must be uniquevalue
- the value to set in this context- Since:
- 5.2.191206
- See Also:
-
getAttribute
Lookup an attribute with the givenname
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, anempty Optional
will be returned.- Type Parameters:
O
- the type of the value to lookup- Parameters:
name
- the name of the attribute to lookup- Returns:
- the first occurrence of the attribute with the given name as an
Optional
- Since:
- 5.2.191206
- See Also:
-
isRelease
boolean isRelease()Indicates whether thiscontext
is based on a release version.- Returns:
true
this context is based on a release version- Since:
- 5.2.191206
- See Also:
-
getLanguage
Returns the currentLanguage
of this generation context.- Returns:
- the current
Language
- Since:
- 5.2.191206
- See Also:
-
getSettings
Returns the currentjson settings
of this generation context.- Returns:
- the current
json settings
o - Since:
- 5.2.191206
- See Also:
-