vendredi 12 avril 2019

Construct object from multiples sources java 8 with custom function

I have multiples sources (Maps) where i store data related to different attributes destined to contruct a final object with an id. These maps have different structures according this pattern :

Map

  • id is the identifier of my final object FinalObject
  • X1, X2 are attributes of my final object FinalObject

in real code i have several map as following :

Map<Integer, String> descriptions;
Map<Integer, Double> prices;
Map<Integer, Double> quantities;
Map<Integer, String> currencies;

I can merge the stream of my collections with Stream.of() but i have two issues to deal with, the structure of heterogenous maps and an also for each entry i want to create a Final object in a Java8 manner.

I think of my MultipleFunction as BiFunction my defined attributes for the FinalObject as arguments. Is it okay as a design ?

Any opionions or advises?

Aucun commentaire:

Enregistrer un commentaire