Package com.microsoft.graph.serializer
Class DefaultSerializer
java.lang.Object
com.microsoft.graph.serializer.DefaultSerializer
- All Implemented Interfaces:
ISerializer
The default serializer implementation for the SDK
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultSerializer(ILogger logger) Creates a DefaultSerializerDefaultSerializer(ILogger logger, boolean serializeNulls) Creates a DefaultSerializer with an option to enable serializing of the null values. -
Method Summary
Modifier and TypeMethodDescription<T> TdeserializeObject(com.google.gson.JsonElement rawElement, Class<T> clazz, Map<String, List<String>> responseHeaders) Deserialize an object from the input JsonElement<T> TdeserializeObject(InputStream inputStream, Class<T> clazz, Map<String, List<String>> responseHeaders) Deserialize an object from the input stream<T> TDeserialize an object from the input stringGets the logger in use<T> StringserializeObject(T serializableObject) Serializes an object into a stringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.microsoft.graph.serializer.ISerializer
deserializeObject, deserializeObject, deserializeObject
-
Constructor Details
-
DefaultSerializer
Creates a DefaultSerializer- Parameters:
logger- the logger
-
DefaultSerializer
Creates a DefaultSerializer with an option to enable serializing of the null values. Serializing of null values can have side effects on the service behavior. Sending null values in a PATCH request might reset existing values on the service side. Sending null values in a POST request might prevent the service from assigning default values to the properties. It is not recommended to send null values to the service in general and this setting should only be used when serializing information for a local store.- Parameters:
logger- the loggerserializeNulls- the setting of whether or not to serialize the null values in the JSON object
-
-
Method Details
-
deserializeObject
@Nullable public <T> T deserializeObject(@Nonnull String inputString, @Nonnull Class<T> clazz, @Nullable Map<String, List<String>> responseHeaders) Description copied from interface:ISerializerDeserialize an object from the input string- Specified by:
deserializeObjectin interfaceISerializer- Type Parameters:
T- the type of the item to be deserialized- Parameters:
inputString- the string that stores the representation of the itemclazz- theClassof the item to be deserializedresponseHeaders- the HTTP response headers- Returns:
- the deserialized item from the input string
-
deserializeObject
@Nullable public <T> T deserializeObject(@Nonnull InputStream inputStream, @Nonnull Class<T> clazz, @Nullable Map<String, List<String>> responseHeaders) Description copied from interface:ISerializerDeserialize an object from the input stream- Specified by:
deserializeObjectin interfaceISerializer- Type Parameters:
T- the type of the item to be deserialized- Parameters:
inputStream- the stream that stores the representation of the itemclazz- theClassof the item to be deserializedresponseHeaders- the HTTP response headers- Returns:
- the deserialized item from the input string
-
deserializeObject
@Nullable public <T> T deserializeObject(@Nonnull com.google.gson.JsonElement rawElement, @Nonnull Class<T> clazz, @Nullable Map<String, List<String>> responseHeaders) Description copied from interface:ISerializerDeserialize an object from the input JsonElement- Specified by:
deserializeObjectin interfaceISerializer- Type Parameters:
T- the type of the item to be deserialized- Parameters:
rawElement- theJsonElementthat stores the representation of the itemclazz- theClassof the item to be deserializedresponseHeaders- the HTTP response headers- Returns:
- the deserialized item from the input string
-
serializeObject
Serializes an object into a string- Specified by:
serializeObjectin interfaceISerializer- Type Parameters:
T- the type of the item to be serialized- Parameters:
serializableObject- the object to convert into a string- Returns:
- the string representation of that item
-
getLogger
Gets the logger in use- Returns:
- a logger
-