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
ConstructorDescriptionBodyAdapterImpl
(com.google.gson.Gson gson, String body, String contentType, String encoding) Constructs a new instance ofBodyAdapterImpl
with 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 aMap
of 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 ofBodyAdapterImpl
with the given parameters.- Parameters:
gson
- TheGson
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
Returns the body of the HTTP request as aString
.- Specified by:
body
in interfaceBodyAdapter
- Returns:
- The body of the HTTP request as a
String
.
-
formData
Returns the form data of the HTTP request as aMap
of key-value pairs.- Specified by:
formData
in interfaceBodyAdapter
- Returns:
- The form data of the HTTP request as a
Map
of key-value pairs.
-
jsonFormat
Returns the JSON representation of the body of the HTTP request as aString
.- Specified by:
jsonFormat
in 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:
urlEncodedFormat
in 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:
modelFormat
in interfaceBodyAdapter
- Parameters:
model
- The class of the model object.- Returns:
- The deserialized model object of the body of the HTTP request.
-