Combine two methods
I have two methods that have exact same conditions but dfferent return values. Anyway to combine these two methods into one and still have two different values?
//getParameter values for aField and bField etc..
.........
String firstSetting ="";
String secondSetting ="";
public String methodOne(){
if ((fieldOne ==null) && (fieldTwo !=null) ){
firstSetting ="firstSetting value: " + aField +" another part of firstSetting";
}
elseif ((fieldOne !=null) && (fieldTwo ==null) ){
firstSetting ="firstSetting value " + bField +" another part of firstSetting";
}
elseif ((fieldOne !=null) && (fieldTwo !=null) ){
firstSetting ="firstSetting value " + bField +" another part of firstSetting " + aField;
}
return firstSetting;
}
public String methodTwo(){
if ((fieldOne ==null) && (fieldTwo !=null) ){
secondSetting ="secondSetting value " + aField;
}
elseif ((fieldOne !=null) && (fieldTwo ==null) ){
secondSetting ="secondSetting value: " + bField;
}
elseif ((fieldOne !=null) && (fieldTwo !=null) ){
secondSetting ="secondSetting value: " + bField +" and " + aField;
}
return secondSetting;
}
.....

