Interface JsonGenerationContext
@NonExtendable
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.- Since:
- 5.2.191206
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceLogger interface used in theJsonGenerationContext. -
Method Summary
Modifier and TypeMethodDescription<O> @NotNull Optional<O>getAttribute(@NotNull String name) Lookup an attribute with the givennamein the current stack.@Nullable LanguageReturns the currentLanguageof this generation context.@NotNull JsonGenerationContext.JsonLoggerReturns theJsonGenerationContext.JsonLoggerof the currentJsonGenerationContext.@NotNull JsonSettingsReturns the currentjson settingsof this generation context.<T> @NotNull JsonElement<?>handle(T object) Entry point for the transformation of an object to aJsonElement.booleanIndicates whether thiscontextis based on a release version.<O> voidsetAttribute(@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,sectionsandtemplateinformation 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.JsonLoggerof 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 givennamewill 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 givennamein 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 Optionalwill 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 thiscontextis based on a release version.- Returns:
truethis context is based on a release version- Since:
- 5.2.191206
- See Also:
-
getLanguage
Returns the currentLanguageof this generation context.- Returns:
- the current
Language - Since:
- 5.2.191206
- See Also:
-
getSettings
Returns the currentjson settingsof this generation context.- Returns:
- the current
json settingso - Since:
- 5.2.191206
- See Also:
-