samedi 24 avril 2021

Create different request objects dynamically

Is it possible to create different objects dynamically from a superset object. For example:

SuperSet Object:

class Z { // some attributes }

class A {
      String a, m, f, c;
      int x,y,z;
      Z z;
}

Child Objects required to be created dynamically from A:

class B {
      String b; // mapped with value of a of A
      String d; // mapped with value of m of A
      int a; // mapped with value of x of A
      int b; // mapped with value of y of A
}

class C {
      String y; // mapped with value of f of A
      String z; // mapped with value of c of A
      int z; // mapped with value of z of A
      Z b; // mapped with value of z of A
}

I would like to create such different child classes having different members which are subset of parent class A.

I know the normal way of creating skeleton class for each child object wanted and then map with values from superset object. Instead is there a way to map different parent class member values to child objects members dynamically.

Aucun commentaire:

Enregistrer un commentaire