lundi 10 août 2015

Design - Check a condition before executing every method

I have a POJO named Document.java with 100+ member variables. There is a transformation layer, where I get the required data, transform it and store it in the Document class.

In the tranformation layer, I would like to set a member variable only if satisfies a certain criteria (based on available context).

So it would look something like this:

if(shouldGetExecuted1(context.getXXX())){
  document.setField1(tranformDataForField1(availableData1));
}

if(shouldGetExecuted2(context.getXXX())){
  document.setField2(tranformDataForField2(availableData2));
}

I want to do this for all the 100+ fields. Is there a clean way to do this?

Aucun commentaire:

Enregistrer un commentaire