Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.
public final class FirestoreValues
- Object
- 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:
| Firestore | Java |
|---|---|
nullValue | null |
booleanValue | Boolean |
integerValue | Long (encoded from any integral type) |
doubleValue | Double (encoded from Float or Double) |
stringValue | String |
timestampValue | Date |
bytesValue | byte[] |
geoPointValue | GeoPoint |
referenceValue | DocumentReference |
arrayValue | List |
mapValue | Map<String, Object> |
Timestamps keep millisecond precision. Firestore stores microseconds, and the extra digits are dropped when decoding.
Methods
Inherited methods
Method details
encode
public static Map<String, Object> encode(Object v)Encodes a Java value.
Parameters
vObject- 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
dataMap- 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
fieldsObject- 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
valueObject- the value map as parsed from JSON
Returns
the Java value, see the class description for the mapping