Interface JsonHandler<T>
- Type Parameters:
T
- The type of the value for which the handler is responsible.
- All Known Subinterfaces:
JsonSupporting<T>
,JsonSupporting<D>
@Experimental
public interface JsonHandler<T>
Interface for converting any object to a specific type of
JsonElement
. The object can be a native
(Integer
, String
, etc...) or a complex (Page
, FormData
, etc...) object.
CAUTION:
This class is still in development and may change drastically without any further notice.- Since:
- 5.2.191206
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionThis method provides the class for which the handler is responsible.@NotNull JsonElement<?>
handle
(@NotNull JsonGenerationContext context, T value) This method transforms the given value to a validJsonElement
.
-
Method Details
-
handle
@NotNull @NotNull JsonElement<?> handle(@NotNull @NotNull JsonGenerationContext context, @NotNull T value) This method transforms the given value to a validJsonElement
. Use json api to create json structure.
Attention: This call should return very fast and should not make any calls to remote services. Example:JsonObject.create(). put(JsonPair.of("myText", JsonStringValue.of(myTextValue))). put(JsonPair.of("myNumber", JsonNumberValue.of(myNumberValue)));
- Parameters:
context
- TheJsonGenerationContext
for rendering this value.value
- The value that needs handling.- Returns:
- A
JsonElement
representing the given value in json. - Since:
- 5.2.191206
- See Also:
-
getSupportedClass
This method provides the class for which the handler is responsible.- Returns:
- The class for which the handler is responsible.
- Since:
- 5.2.191206
- See Also:
-