dimanche 24 février 2019

I have a big pojo with exhaustive data and i want to create attribute sets out of them efficiently that different services may use

The problem statement is simple. I have a big pojo with several properties and i want to logically organize them into sets.

eg.

class A{
  Property prop1, prop2, prop3..... propn;
}

I want to have several property sets.

Eg. -

Set A has { prop1, prop3, prop5, propn}
Set B has {prop1, prop2, prop4, prop5}
Set C has {prop1, prop2, propn_1, propn}
....

Suppose, some service A wants setA of data i could return that. Or if some service wants setA&setB, i could do that as well.

My question is:

Can this be elegantly represented in java OOP design. Is there any design pattern that can fit here. Plus it would be really great if i could just return a abstract or generic pojo from the layer thats interacts with the pojo A. At the api layer, if I could just do returnedPojo.build() or something like that and just serialize - that would be great.

TIA.

Aucun commentaire:

Enregistrer un commentaire