Just a random post for everyone.
If you don't know what Plain Old Java Object (POJO) is, take a look at Wikipedia's explanation thereof.
I have written a simple POJO instantiator. This instantiator is not fully perfect but it does what it was designed thus far.
My criteria I have choose of what constitutes a POJO is simple:
- A class must have a no constructor at all, or a public zero-argument constructor.
- The instance variables must have a respective getter and setter method (of which, both must be public).
- It never instantiates a final instance or a static final instance.
serialVersionUID
is ignored.- Array instance variables are not instantiated.
- Any instance variable which has the same type as the class it is declared is not instantiated. The reason is that the utility class will go into an infinite recursive loop and a
StackOverflowError
is thrown.
If you have found any issues or have further things to see from this utility, please feel free to comment below or give a shout out! :-)
Happy coding! :-)
Comments
Post a Comment