SerializerAdapter Interface
public interface SerializerAdapter
An interface defining the behaviors of a serializer.
Method Summary
Modifier and Type | Method and Description |
---|---|
default T |
deserialize(byte[] bytes, Type type, SerializerEncoding encoding)
Deserializes a byte array into an object. |
abstract T |
deserialize(HttpHeaders headers, Type type)
Deserialize the provided headers returned from a REST API to an entity instance declared as the model to hold 'Matching' headers. |
default T |
deserialize(InputStream inputStream, Type type, SerializerEncoding encoding)
Deserializes a stream into an object. |
abstract T |
deserialize(String value, Type type, SerializerEncoding encoding)
Deserializes a string into an object. |
default T |
deserializeHeader(Header header, Type type)
Deserializes the provided header returned from a REST API to en entity instance declared as the model of the header. |
abstract String |
serialize(Object object, SerializerEncoding encoding)
Serializes an object into a string. |
default void |
serialize(Object object, SerializerEncoding encoding, OutputStream outputStream)
Serializes an object and writes its output into an OutputStream. |
default String |
serializeIterable(Iterable<?> iterable, CollectionFormat format)
Serializes an iterable into a string with the delimiter specified with the Swagger collection format joining each individual serialized items in the list. |
abstract String |
serializeList(List<?> list, CollectionFormat format)
Serializes a list into a string with the delimiter specified with the Swagger collection format joining each individual serialized items in the list. |
abstract String |
serializeRaw(Object object)
Serializes an object into a raw string, leading and trailing quotes will be trimmed. |
default byte[] |
serializeToBytes(Object object, SerializerEncoding encoding)
Serializes an object into a byte array. |
Method Details
deserialize
public default T
Deserializes a byte array into an object.
Parameters:
Returns:
Throws:
deserialize
public abstract T
Deserialize the provided headers returned from a REST API to an entity instance declared as the model to hold 'Matching' headers.
'Matching' headers are the REST API returned headers those with:
- header names same as name of a properties in the entity.
- header names start with value of HeaderCollection annotation applied to the properties in the entity.
When needed, the 'header entity' types must be declared as first generic argument of ResponseBase<H,T> returned by java proxy method corresponding to the REST API. e.g. Mono> getMetadata(args);
class FooMetadataHeaders { String name; {@literal @}HeaderCollection("header-collection-prefix-") Map headerCollection; }
in the case of above example, this method produces an instance of FooMetadataHeaders from provided headers
.
Parameters:
Returns:
headers
, if header entity model does
not exist then return nullThrows:
deserialize
public default T
Deserializes a stream into an object.
Parameters:
Returns:
Throws:
deserialize
public abstract T
Deserializes a string into an object.
Parameters:
Returns:
Throws:
deserializeHeader
public default T
Deserializes the provided header returned from a REST API to en entity instance declared as the model of the header.
Parameters:
Returns:
Throws:
serialize
public abstract String serialize(Object object, SerializerEncoding encoding)
Serializes an object into a string.
Parameters:
Returns:
Throws:
serialize
public default void serialize(Object object, SerializerEncoding encoding, OutputStream outputStream)
Serializes an object and writes its output into an OutputStream.
Parameters:
Throws:
serializeIterable
public default String serializeIterable(Iterable> iterable, CollectionFormat format)
Serializes an iterable into a string with the delimiter specified with the Swagger collection format joining each individual serialized items in the list.
Parameters:
Returns:
serializeList
public abstract String serializeList(List> list, CollectionFormat format)
Serializes a list into a string with the delimiter specified with the Swagger collection format joining each individual serialized items in the list.
Parameters:
Returns:
serializeRaw
public abstract String serializeRaw(Object object)
Serializes an object into a raw string, leading and trailing quotes will be trimmed.
Parameters:
Returns:
serializeToBytes
public default byte[] serializeToBytes(Object object, SerializerEncoding encoding)
Serializes an object into a byte array.
Parameters:
Returns:
Throws:
Applies to
Azure SDK for Java
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for