1

I have a class with constructor and getters:

Animal {
   boolean herbivore;
   boolean carnivore;
   boolean omnivore; }

And I also have 2 constructors with only herbivore/carnivore fields.

Its possible to use @Exclude on getters when writing in firestore document, so there is no empty fields like this:

herbivore: true;

instead of like this:

carnivore: null;
herbivore: true;
omnivore : null;

But, when reading, if a getter is marked with @Exclude, it will not be read. Is it posible to use @Exclude only when writing and not when reading?

Nemanja
  • 211
  • 6
  • 16

1 Answers1

0

Unfortunately the Exclude annotation works on both reads and writes. The only way to determine on a per-field level what gets written is to pass it as a Map of precisely the values you want.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807