I have a a few lines of code which repeat itself in many methods:
public String removeItemsX() {
MyReq myReq = new MyReq();
myReq.setName(<String>);
StandardResponse standardResponse = null;
try {
standardResponse = A.removeItemX(myReq); // This method call is different, the rest is the same
} catch (Exception ex) {
...
}
return standardResponse;
}
Now I have many methods
removeItemX();
removeItemY();
removeItemZ();
...
which have almost the same code above, just the method calls are different:
A.removeItemX(myReq);
A.removeItemY(myReq);
A.removeItemZ(myReq);
...
Is it possible to define just one method, an pass into somehow only the different method calls?