【问题标题】:Exclude fields from Superclass in Cloud Firestore serialization?在 Cloud Firestore 序列化中从超类中排除字段?
【发布时间】:2017-11-06 10:33:00
【问题描述】:

我正在使用 Cloud Firestore,并且我的一些类从外部库扩展(只有读取权限)。 当一个对象被保存到 Firestore 时,超类中的所有字段也都包括在内。 我找到了@Exclude 和@IgnoreExtraProperties 注释。但是,由于我只有对超类的读取权限,因此无法将它们包含在我的代码中。

有没有办法在序列化中完全“忽略”超类?

【问题讨论】:

    标签: android serialization google-cloud-firestore


    【解决方案1】:

    您无法忽略从 SuperClass 继承的字段。因为您只有读取权限,所以无法从您的 SuperClass 添加/更改 annotations

    你可以要求超类的所有者将字段从公共更改为private。这样,您只能通过 setter 和 getter 访问它们,并且这些字段将不再被继承。

    【讨论】:

      猜你喜欢
      • 2013-01-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-04-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多