I have two classes:
class a
( Parent )class b
( Child )b extend a
These classes only store data as a structure, nothing more.
I need to convert class b
to class a
.
I know that it is not necessary to do this at all, since he is already a successor of class a
. But I use a library that saves objects according to their affiliation.
I get class a
class b
object in the class a
constructor, and manually assign all the fields there. But this solution looks bad, especially since there are about 30 fields.
Is it possible to somehow do this through a cycle, or to automate this process altogether?
PS Java I use in Android development.
UPD :
These classes have no heteros and setters; all their fields that need to be filled are public, and I’m not manually assigning them to this point myself - the library does it somewhere inside.