lundi 18 juin 2018

calling the class based on the value of parameter

I have the below interface

public Map<String, List<SSTU>> exceute(Map<String, String> SSTUInputparams) throws BuisnessRuleException;

and I have the below two implemetation classes of it

the very first class

public class firstClass implements SSTUbusinessRule
{

public Map<String, List<SSTU>> exceute(Map<String, String> SSTUInputparams) throws BuisnessRuleException {
}


}

and the second class

public class secondClass implements SSTUbusinessRule
{

public Map<String, List<SSTU>> exceute(Map<String, String> SSTUInputparams) throws BuisnessRuleException {
}


}

now my above code classes is being from some other part as shown below as they pass the parameters to my classes

HashMap<String,String> hm=new HashMap<String,String>();  
  hm.put("A,"aaa");  
  hm.put(NR,"I");   // **** so the value of NR key can be I , A OR B

Map<String, List<SSTU>> aSSTUMap =  firstClass.exceute(Map<String, String> SSTUInputparams);
Map<String, List<SSTU>> CcquirerSSTUMap =   secondClass.exceute(Map<String, String> SSTUInputparams);

now what change i need to bring in them is lets say in map the value of parameter NR is of type I then execute the first class execute method and if the value of NR is of type A then execute the second class and if the value of type NR is of type B then execute both first class and second class

Now please advise how to achieve the same as i think I have to read the hashmap first inside the classes and then should I decide.

Aucun commentaire:

Enregistrer un commentaire