Class BodyAdapterImpl

java.lang.Object
com.creativityfactory.swiftserver.utils.BodyAdapterImpl
All Implemented Interfaces:
BodyAdapter

public class BodyAdapterImpl extends Object implements BodyAdapter
Implementation of BodyAdapter interface, which adapts the body of an HTTP request into various formats.
  • Constructor Details

    • BodyAdapterImpl

      public BodyAdapterImpl(com.google.gson.Gson gson, String body, String contentType, String encoding)
      Constructs a new instance of BodyAdapterImpl with the given parameters.
      Parameters:
      gson - The Gson instance to use for serialization/deserialization.
      body - The body of the HTTP request to be adapted.
      contentType - The content type of the HTTP request.
      encoding - The encoding of the HTTP request.
  • Method Details

    • body

      public String body()
      Returns the body of the HTTP request as a String.
      Specified by:
      body in interface BodyAdapter
      Returns:
      The body of the HTTP request as a String.
    • formData

      public Map<String,String> formData()
      Returns the form data of the HTTP request as a Map of key-value pairs.
      Specified by:
      formData in interface BodyAdapter
      Returns:
      The form data of the HTTP request as a Map of key-value pairs.
    • jsonFormat

      public String jsonFormat()
      Returns the JSON representation of the body of the HTTP request as a String.
      Specified by:
      jsonFormat in interface BodyAdapter
      Returns:
      The JSON representation of the body of the HTTP request as a String.
    • urlEncodedFormat

      public String urlEncodedFormat()
      Returns the URL-encoded representation of the body of the HTTP request as a String.
      Specified by:
      urlEncodedFormat in interface BodyAdapter
      Returns:
      The URL-encoded representation of the body of the HTTP request as a String.
    • modelFormat

      public Object modelFormat(Class<?> model)
      Returns the deserialized model object of the body of the HTTP request.
      Specified by:
      modelFormat in interface BodyAdapter
      Parameters:
      model - The class of the model object.
      Returns:
      The deserialized model object of the body of the HTTP request.