Class DefaultSerializer

java.lang.Object
com.microsoft.graph.serializer.DefaultSerializer
All Implemented Interfaces:
ISerializer

public class DefaultSerializer extends Object implements ISerializer
The default serializer implementation for the SDK
  • Constructor Details

    • DefaultSerializer

      public DefaultSerializer(@Nonnull ILogger logger)
      Creates a DefaultSerializer
      Parameters:
      logger - the logger
    • DefaultSerializer

      public DefaultSerializer(@Nonnull ILogger logger, @Nonnull boolean serializeNulls)
      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 logger
      serializeNulls - 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: ISerializer
      Deserialize an object from the input string
      Specified by:
      deserializeObject in interface ISerializer
      Type Parameters:
      T - the type of the item to be deserialized
      Parameters:
      inputString - the string that stores the representation of the item
      clazz - the Class of the item to be deserialized
      responseHeaders - 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: ISerializer
      Deserialize an object from the input stream
      Specified by:
      deserializeObject in interface ISerializer
      Type Parameters:
      T - the type of the item to be deserialized
      Parameters:
      inputStream - the stream that stores the representation of the item
      clazz - the Class of the item to be deserialized
      responseHeaders - 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: ISerializer
      Deserialize an object from the input JsonElement
      Specified by:
      deserializeObject in interface ISerializer
      Type Parameters:
      T - the type of the item to be deserialized
      Parameters:
      rawElement - the JsonElement that stores the representation of the item
      clazz - the Class of the item to be deserialized
      responseHeaders - the HTTP response headers
      Returns:
      the deserialized item from the input string
    • serializeObject

      @Nullable public <T> String serializeObject(@Nonnull T serializableObject)
      Serializes an object into a string
      Specified by:
      serializeObject in interface ISerializer
      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

      @Nullable public ILogger getLogger()
      Gets the logger in use
      Returns:
      a logger