Class BodyAdapterImpl
java.lang.Object
com.creativityfactory.swiftserver.utils.BodyAdapterImpl
- All Implemented Interfaces:
BodyAdapter
Implementation of
BodyAdapter interface, which adapts the body of an HTTP request into various formats.-
Constructor Summary
ConstructorsConstructorDescriptionBodyAdapterImpl(com.google.gson.Gson gson, String body, String contentType, String encoding) Constructs a new instance ofBodyAdapterImplwith the given parameters. -
Method Summary
Modifier and TypeMethodDescriptionbody()Returns the body of the HTTP request as aString.formData()Returns the form data of the HTTP request as aMapof key-value pairs.Returns the JSON representation of the body of the HTTP request as aString.modelFormat(Class<?> model) Returns the deserialized model object of the body of the HTTP request.Returns the URL-encoded representation of the body of the HTTP request as aString.
-
Constructor Details
-
BodyAdapterImpl
Constructs a new instance ofBodyAdapterImplwith the given parameters.- Parameters:
gson- TheGsoninstance 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
Returns the body of the HTTP request as aString.- Specified by:
bodyin interfaceBodyAdapter- Returns:
- The body of the HTTP request as a
String.
-
formData
Returns the form data of the HTTP request as aMapof key-value pairs.- Specified by:
formDatain interfaceBodyAdapter- Returns:
- The form data of the HTTP request as a
Mapof key-value pairs.
-
jsonFormat
Returns the JSON representation of the body of the HTTP request as aString.- Specified by:
jsonFormatin interfaceBodyAdapter- Returns:
- The JSON representation of the body of the HTTP request as a
String.
-
urlEncodedFormat
Returns the URL-encoded representation of the body of the HTTP request as aString.- Specified by:
urlEncodedFormatin interfaceBodyAdapter- Returns:
- The URL-encoded representation of the body of the HTTP request as a
String.
-
modelFormat
Returns the deserialized model object of the body of the HTTP request.- Specified by:
modelFormatin interfaceBodyAdapter- Parameters:
model- The class of the model object.- Returns:
- The deserialized model object of the body of the HTTP request.
-