2 / 2
Jul 2024

I am wondering if there are any examples of client code which builds custom logic to control how pojos are serialized and deserialized. The standard logic provided to serialize and deserialize pojos just does not do what I would like. The biggest thing is probably that I do not like having to make my setters and gettes public. I prefer to set the permissions on these based on my business logic. Some fields should just not be accessed by clients of my module.

In any case, I was considering trying to write my own ClassModelBuilder which creates PropertyModels underneath which use java reflection to set and get the attribute values directly. However, I can not figure out how to do this. I can not extend the ClassModelBuilder class because the constructor is package access. Or is this not something that is anticipated for client code to be able to do? I have not been able to find anything which discusses this at all.

I appreciate any help you can give. Or just tell me I am totally taking the wrong approach with it. My other option is to give up on the pojo support and work with the Document APIs. But that just seems like a huge waste. It seems a lot better to work within the framework that exists for pojos.