Firebase @PropertyName doesn't work

后端 未结 3 1669
不知归路
不知归路 2020-11-28 09:22

THE STORY

I am using Firebase Realtime Database in my app. I have a model something like this.

class Item {
    int mItemName;
    /         


        
3条回答
  •  时光说笑
    2020-11-28 09:58

    Alternatively just mark your getters with @PropertyName instead of annotating properties themselves - this way you can keep properties private while providing custom names:

    public class User extends Object {
    
        private String mDisplayName;
    
    
        @PropertyName("userName")
        public String getDisplayName() {
            return mDisplayName;
        }
    
        @PropertyName("userName")
        public void setDisplayName(String displayName) {
            mDisplayName = displayName;
        }
    
    }
    

提交回复
热议问题