IMPORTANT: In July 2025, we stopped releasing new versions of KTX modules, and we removed the KTX libraries from the Firebase Android BoM (v34.0.0). If you use KTX APIs from the previously released KTX modules, we recommend that youmigrate your app to use KTX APIs from the main modules instead. For details, see theFAQ about this initiative.
PropertyName
@Retention(value = RetentionPolicy.RUNTIME)
@Target(value = [ElementType.METHOD, ElementType.FIELD])
public annotationPropertyName
Marks a field to be renamed when serialized.
Kotlin Note
When applying this annotation to a property of a Kotlin class, both the@get and@set use-site targets should be used. Here is an example of a class that can both be written into and read from Firestore whosefoo property will be stored into and read from a field namedmy_foo in the Firestore document:
dataclassPojo(@get:PropertyName("my_foo")@set:PropertyName("my_foo")varfoo:String?=null){constructor():this(null)//UsedbyFirestoretocreatenewinstances}
If the class only needs to bewritten into Firestore (and not read from Firestore) then the class can be simplified as follows:
dataclassPojo(@get:PropertyName("my_foo")valfoo:String?=null)var can be tightened toval, the secondary no-argument constructor can be omitted, and the@set use-site target can be omitted.Summary
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-07-21 UTC.