Class JsonSupport

All Implemented Interfaces:
RuntimeType.Api<JsonSupportConfig>, NamedService, NamedService, MediaSupport

public class JsonSupport extends MediaSupportBase<JsonSupportConfig> implements RuntimeType.Api<JsonSupportConfig>
Helidon JSON media support.

This media support adds serialization and deserialization for JsonValue.

  • Field Details

    • JSON_OBJECT_TYPE

      public static final GenericType<JsonObject> JSON_OBJECT_TYPE
      Generic type of this type, as it is required when this media type is used programmatically.
  • Method Details

    • create

      public static JsonSupport create()
      Create a new instance of JSON Support with default configuration.
      Returns:
      json media support for JsonValue
    • builder

      public static JsonSupportConfig.Builder builder()
      Create a new builder for JsonSupport.
      Returns:
      a new builder instance
    • create

      public static JsonSupport create(JsonSupportConfig config)
      Create a new Helidon JSON support from a configuration object.
      Parameters:
      config - the configuration object
      Returns:
      a new JsonSupport instance
    • serverResponseWriter

      public static EntityWriter<JsonObject> serverResponseWriter()
      Create a JSON writer with default settings.
      Returns:
      a writer for JsonObject
    • prototype

      public JsonSupportConfig prototype()
      Description copied from interface: RuntimeType.Api
      The prototype as it was received when creating this runtime object instance.
      Specified by:
      prototype in interface RuntimeType.Api<JsonSupportConfig>
      Returns:
      prototype object used to create this instance
    • reader

      public <T> MediaSupport.ReaderResponse<T> reader(GenericType<T> type, Headers requestHeaders)
      Description copied from interface: MediaSupport
      Reader for an entity.
      Specified by:
      reader in interface MediaSupport
      Type Parameters:
      T - type
      Parameters:
      type - type of entity
      requestHeaders - headers belonging to this entity (such as server request headers), expected to have content type
      Returns:
      reader response, whether this type is supported or not
    • writer

      public <T> MediaSupport.WriterResponse<T> writer(GenericType<T> type, Headers requestHeaders, WritableHeaders<?> responseHeaders)
      Description copied from interface: MediaSupport
      Server response writer.
      Specified by:
      writer in interface MediaSupport
      Type Parameters:
      T - type
      Parameters:
      type - type of entity
      requestHeaders - request headers
      responseHeaders - response headers
      Returns:
      writer response, whether this type is supported or not
    • reader

      public <T> MediaSupport.ReaderResponse<T> reader(GenericType<T> type, Headers requestHeaders, Headers responseHeaders)
      Description copied from interface: MediaSupport
      Client response reader.
      Specified by:
      reader in interface MediaSupport
      Type Parameters:
      T - type
      Parameters:
      type - type of entity
      requestHeaders - request headers
      responseHeaders - response headers
      Returns:
      reader response, whether this type is supported or not
    • writer

      public <T> MediaSupport.WriterResponse<T> writer(GenericType<T> type, WritableHeaders<?> requestHeaders)
      Description copied from interface: MediaSupport
      Client request writer.
      Specified by:
      writer in interface MediaSupport
      Type Parameters:
      T - type
      Parameters:
      type - type of entity
      requestHeaders - request headers
      Returns:
      writer response, whether this type is supported or not
    • canSerialize

      protected boolean canSerialize(GenericType<?> type)
      Description copied from class: MediaSupportBase
      Check whether the type is supported by this media support for serialization.
      Specified by:
      canSerialize in class MediaSupportBase<JsonSupportConfig>
      Parameters:
      type - type to check
      Returns:
      whether this media support can handle this type
    • canDeserialize

      protected boolean canDeserialize(GenericType<?> type)
      Description copied from class: MediaSupportBase
      Check whether the type is supported by this media support for deserialization.
      Specified by:
      canDeserialize in class MediaSupportBase<JsonSupportConfig>
      Parameters:
      type - type to check
      Returns:
      whether this media support can handle this type