Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.

public final class FirestoreValues

  1. Object
  2. FirestoreValues

Converts between plain Java values and the Firestore REST value encoding.

Firestore wraps every value in a single-key map naming its type, such as {"integerValue": "42"}. This class maps those to Java types and back:

FirestoreJava
nullValuenull
booleanValueBoolean
integerValueLong (encoded from any integral type)
doubleValueDouble (encoded from Float or Double)
stringValueString
timestampValueDate
bytesValuebyte[]
geoPointValueGeoPoint
referenceValueDocumentReference
arrayValueList
mapValueMap<String, Object>

Timestamps keep millisecond precision. Firestore stores microseconds, and the extra digits are dropped when decoding.

Methods

public static Map<String, Object> encode(Object v)Encodes a Java value.
public static Map<String, Object> encodeFields(Map data)Encodes every entry of a map, producing a document’s fields object.
public static Map<String, Object> decodeFields(Object fields)Decodes a document’s fields object.
public static Object decode(Object value)Decodes a Firestore value map.

Inherited methods

Method details

encode

public static Map<String, Object> encode(Object v)
Encodes a Java value.

Parameters

v Object
a value of one of the supported types

Returns

the Firestore value map

Throws

IllegalArgumentException
for an unsupported type

encodeFields

public static Map<String, Object> encodeFields(Map data)
Encodes every entry of a map, producing a document’s fields object.

Parameters

data Map
field names to Java values

Returns

field names to Firestore value maps

decodeFields

public static Map<String, Object> decodeFields(Object fields)
Decodes a document’s fields object.

Parameters

fields Object
field names to Firestore value maps, may be null

Returns

field names to Java values, never null

decode

public static Object decode(Object value)
Decodes a Firestore value map.

Parameters

value Object
the value map as parsed from JSON

Returns

the Java value, see the class description for the mapping