Class CustomClassMapper

java.lang.Object
com.google.cloud.firestore.encoding.CustomClassMapper

@InternalApi public class CustomClassMapper extends Object
Helper class to convert to/from custom POJO classes and plain Java types.
  • Constructor Details

    • CustomClassMapper

      public CustomClassMapper()
  • Method Details

    • convertToPlainJavaTypes

      public static Object convertToPlainJavaTypes(Object object)
      Converts a Java representation of JSON data to standard library Java data types: Map, Array, String, Double, Integer and Boolean. POJOs are converted to Java Maps.
      Parameters:
      object - The representation of the JSON data
      Returns:
      JSON representation containing only standard library Java types
    • convertToPlainJavaTypes

      public static Map<String,Object> convertToPlainJavaTypes(Map<?,Object> update)
    • convertToCustomClass

      public static <T> T convertToCustomClass(Object object, Class<T> clazz, DocumentReference docRef)
      Converts a standard library Java representation of JSON data to an object of the provided class.
      Parameters:
      object - The representation of the JSON data
      clazz - The class of the object to convert to
      docRef - The value to set to DocumentId annotated fields in the custom class.
      Returns:
      The POJO object.
    • serialize

      public static <T> Object serialize(T o)