I have serialization working fine for the entire application state for loading/saving. I've properly marked fields as transient that can't or shouldn't be written to disk.
Now I want to save a template or schematic of ONE specific class in the application that can be read back later to replace just that ONE class in the app.
Here's the annoyance - the smaller template/schematic includes fields that are NOT marked as transient, because they are needed for the entire saved application state. They are not needed for the template/schematic, as their values will be replaced upon loading that specific template/schematic anyway. Due to these extra fields, the saved serialized data balloons from 10K to almost 300k.
Yes, in this day and age of 20TB drives, this doesn't sound like much of a problem. However, these schematics will be shared with random other people on the internet. They need to be trimmed and cleaned up as much as possible.
The number of variables I do want far exceeds the number I don't want, making it a nightmare to write a custom serialization method.
With my limited knowledge, I see only two options here:
1. Write a custom serialization readObject and writeObject.
I don't really want to do this because of the sheer number of fields I would be dealing with here.
2. null the fields I don't want and then restore them after saving.
I already have to restore these when loading the schematic, since the running application will have updated pointers to classes that were not needed or saved in the schematic.
I'm hoping someone has dealt with this and has a clever way to do what I'm trying to do.