How can I make one method generic method doRetry
out of these two methods doRetryA
and doRetryB
in Java where moth boths execute similar code but differs in func1
and func2 calls where func1 and func2
take same number of arguments and these arguments are same types but func1 and func2
differs in functionalities but return same type?
SomeType foo = someEnum.enumValue;
private SomeType def doRetryA() {
for(int attempt=0; attempt<retries; attempt++) {
foo = func1(a, b);
return foo;
}
private SomeType def doRetryB() {
for(int attempt=0; attempt<retries; attempt++) {
foo = func2(a, b);
return foo;
}